Encoder, a decoder and corresponding methods for inter prediction

ABSTRACT

A bidirectional optical flowing prediction method includes obtaining an initial motion vector pair for a current block, obtaining a forward and a backward prediction block according to the forward motion vector and a backward prediction block according to the initial motion vector pair, and calculating gradient parameters for a current sample in the current block. The method further includes obtaining at least two sample optical flow parameters, including a first parameter and a second parameter, for the current sample based on the gradient parameters, obtaining block optical flow parameters based on sample optical flow parameters of samples in the current block, and obtaining a prediction value of the current block. One of the block optical flow parameters is obtained by multiplying the first parameter and a sign function of the second parameter, and the sign function is a piecewise function with at least three subintervals.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No. PCT/CN2020/077121, filed on Feb. 28, 2020, which claims priority to Indian Provisional Patent Application No. IN201931009184, filed on Mar. 8, 2019. The disclosures of the aforementioned applications are hereby incorporated by reference in their entireties.

TECHNICAL FIELD

Embodiments of the present application generally relate to the field of picture processing and more particularly to inter prediction.

BACKGROUND

Video coding (video encoding and decoding) is used in a wide range of digital video applications, for example broadcast digital TV, video transmission over internet and mobile networks, real-time conversational applications such as video chat, video conferencing, DVD and Blu-ray discs, video content acquisition and editing systems, and camcorders of security applications.

The amount of video data needed to depict even a relatively short video might be substantial, which may result in difficulties when the data is to be streamed or otherwise communicated across a communications network with limited bandwidth capacity. Thus, video data is generally compressed before being communicated across modern day telecommunications networks. The size of a video could also be an issue when the video is stored on a storage device because memory resources may be limited. Video compression devices often use software and/or hardware at the source to code the video data prior to transmission or storage, thereby decreasing the quantity of data needed to represent digital video images. The compressed data is then received at the destination by a video decompression device that decodes the video data. With limited network resources and ever increasing demands of higher video quality, improved compression and decompression techniques that improve compression ratio with little to no sacrifice in picture quality are desirable.

SUMMARY

Embodiments of the present application provide apparatuses and methods for encoding and decoding according to the independent claims.

In a first aspect of the present application, a bidirectional optical flowing prediction method, comprising: obtaining an initial motion vector pair for a current block, wherein the initial motion vector pair comprises a forward motion vector and a backward motion vector; obtaining a forward prediction block according to the forward motion vector and a backward prediction block according to the backward motion vector; calculating gradient parameters for a current sample in the current block based on a forward prediction sample and a backward prediction sample corresponding to the current sample, wherein the forward prediction sample is in the forward prediction block and the backward prediction sample is in the backward prediction block; obtaining at least two sample optical flow parameters for the current sample based on the gradient parameters, wherein the sample optical flow parameters comprises a first parameter and a second parameter; obtain block optical flow parameters based on sample optical flow parameters of samples in the current block, wherein one of the block optical flow parameters is obtained by an operation including multiplying a value of the first parameter and a value of a sign function of the second parameter, and wherein the sign function is a piecewise function with at least three subintervals; and obtaining a prediction value of the current block based on the forward prediction block, the backward prediction block, the block optical flow parameters and the sample optical flow parameters.

In a feasible implementation, the sign function is

${{Sign}(x)} = \left\{ \begin{matrix} {1;} & {x > T} \\ {0\ ;} & {{- T} \leqslant x \leqslant T} \\ {{- 1};} & {x < {- T}} \end{matrix} \right.$

wherein T is a non-negative real number.

In a feasible implementation, T is 0; correspondingly, the sign function is

${{Sign}(x)} = \left\{ \begin{matrix} {1;} & {x > 0} \\ {0;} & {x==0} \\ {{- 1};} & {x < 0} \end{matrix} \right.$

In a feasible implementation, the initial motion vector pair is obtained according to motion information of at least one spatial and/or temporal neighboring block of the current block. In a feasible implementation, the current block is a coding unit or a sub-block of the coding unit.

In a feasible implementation, gradient parameters comprise a forward horizontal gradient, a backward horizontal gradient, a forward vertical gradient and a backward vertical gradient.

In a feasible implementation, the forward horizontal gradient is a difference of a right sample and a left sample adjacent to the forward prediction sample.

In a feasible implementation, the backward horizontal gradient is a difference of a right sample and a left sample adjacent to the backward prediction sample.

In a feasible implementation, the forward vertical gradient is a difference of a bottom sample and an upper sample adjacent to the forward prediction sample.

In a feasible implementation, the backward vertical gradient is a difference of a bottom sample and an upper sample adjacent to the backward prediction sample.

In a feasible implementation, the sample optical flow parameters comprise a sample difference, a horizontal average gradient and a vertical average gradient.

In a feasible implementation, the first parameter is the sample difference, the horizontal average gradient or the vertical average gradient.

In a feasible implementation, the second parameter is the sample difference, the horizontal average gradient or the vertical average gradient, and the second parameter is not the first parameter.

In a second aspect of the present application, a bidirectional optical flowing prediction apparatus, comprising: an obtaining module, configured to obtain an initial motion vector pair for a current block, wherein the initial motion vector pair comprises a forward motion vector and a backward motion vector; a patching module, configured to obtain a forward prediction block according to the forward motion vector and a backward prediction block according to the backward motion vector; a gradient module, configured to calculate gradient parameters for a current sample in the current block based on a forward prediction sample and a backward prediction sample corresponding to the current sample, wherein the forward prediction sample is in the forward prediction block and the backward prediction sample is in the backward prediction block; a calculating module, configured to obtain at least two sample optical flow parameters for the current sample based on the gradient parameters, wherein the sample optical flow parameters comprises a first parameter and a second parameter; a training module, configured to obtain block optical flow parameters based on sample optical flow parameters of samples in the current block, wherein one of the block optical flow parameters is obtained by an operation including multiplying a value of the first parameter and a value of a sign function of the second parameter, and wherein the sign function is a piecewise function with at least three subintervals; and a predicting module, configured to obtain a prediction value of the current block based on the forward prediction block, the backward prediction block, the block optical flow parameters and the sample optical flow parameters.

In a feasible implementation, the sign function is

${{Sign}(x)} = \left\{ \begin{matrix} {1;} & {x > T} \\ {0;} & {{- T} \leqslant x \leqslant T} \\ {{- 1};} & {x < \ {- T}} \end{matrix} \right.$

wherein T is a non-negative real number.

In a feasible implementation, T is 0; correspondingly, the sign function is

${{Sign}(x)} = \left\{ \begin{matrix} {1;} & {x > 0} \\ {0;} & {x==0} \\ {{- 1};} & {x < 0} \end{matrix} \right.$

In a feasible implementation, the initial motion vector pair is obtained according to motion information of at least one spatial and/or temporal neighboring block of the current block.

In a feasible implementation, the current block is a coding unit or a sub-block of the coding unit.

In a feasible implementation, gradient parameters comprise a forward horizontal gradient, a backward horizontal gradient, a forward vertical gradient and a backward vertical gradient.

In a feasible implementation, the forward horizontal gradient is a difference of a right sample and a left sample adjacent to the forward prediction sample.

In a feasible implementation, the backward horizontal gradient is a difference of a right sample and a left sample adjacent to the backward prediction sample.

In a feasible implementation, the forward vertical gradient is a difference of a bottom sample and an upper sample adjacent to the forward prediction sample.

In a feasible implementation, the backward vertical gradient is a difference of a bottom sample and an upper sample adjacent to the backward prediction sample.

In a feasible implementation, the sample optical flow parameters comprise a sample difference, a horizontal average gradient and a vertical average gradient.

In a feasible implementation, the first parameter is the sample difference, the horizontal average gradient or the vertical average gradient.

In a feasible implementation, the second parameter is the sample difference, the horizontal average gradient or the vertical average gradient, and the second parameter is not the first parameter.

In a third aspect of the present application, a bidirectional optical flowing prediction apparatus, comprising: one or more processors; and a non-transitory computer-readable storage medium coupled to the processors and storing programming for execution by the processors, wherein the programming, when executed by the processors, configures the apparatus to carry out the method according to any one of implementations of the first aspect of the present application.

In a fourth aspect of the present application, a computer program product comprising a program code for performing the method according to any one of implementations of the first aspect of the present application.

In a fifth aspect of the present application, a decoder, comprising: one or more processors; and a non-transitory computer-readable storage medium coupled to the processors and storing programming for execution by the processors, wherein the programming, when executed by the processors, configures the decoder to carry out the method according to any one of implementations of the first aspect of the present application.

In a sixth aspect of the present application, an encoder, comprising: one or more processors; and a non-transitory computer-readable storage medium coupled to the processors and storing programming for execution by the processors, wherein the programming, when executed by the processors, configures the encoder to carry out the method according to any one of implementations of the first aspect of the present application.

In a seventh aspect of the present application, a bitstream is produced according to any one of implementations of the first aspect of the present application.

The foregoing and other objects are achieved by the subject matter of the independent claims. Further implementation forms are apparent from the dependent claims, the description and the figures.

Particular embodiments are outlined in the attached independent claims, with other embodiments in the dependent claims.

Details of one or more embodiments are set forth in the accompanying drawings and the description below. Other features, objects, and advantages will be apparent from the description, drawings, and claims.

BRIEF DESCRIPTION OF THE DRAWINGS

In the following embodiments of the application are described in more detail with reference to the attached figures and drawings, in which:

FIG. 1A is a block diagram showing an example of a video coding system configured to implement embodiments of the application;

FIG. 1B is a block diagram showing another example of a video coding system configured to implement embodiments of the application;

FIG. 2 is a block diagram showing an example of a video encoder configured to implement embodiments of the application;

FIG. 3 is a block diagram showing an example structure of a video decoder configured to implement embodiments of the application;

FIG. 4 is a block diagram illustrating an example of an encoding apparatus or a decoding apparatus;

FIG. 5 is a block diagram illustrating another example of an encoding apparatus or a decoding apparatus;

FIG. 6 illustrates an example of ternary valued output function;

FIG. 7 illustrates an example of 5-valued output function;

FIG. 8 is a block diagram illustrating an example of a bidirectional optical flow prediction process of the present application;

FIG. 9 is a block diagram illustrating another example of the bidirectional optical flow prediction process of the present application;

FIG. 10 is a block diagram illustrating an example of a bidirectional optical flow prediction apparatus of the present application;

FIG. 11 is a block diagram illustrating another example of a bidirectional optical flow prediction apparatus of the present application;

FIG. 12 is a block diagram illustrating an example of an apparatus for inter prediction according to the present application;

FIG. 13 is a block diagram illustrating another example of an apparatus for inter prediction according to the present application.

In the following identical reference signs refer to identical or at least functionally equivalent features if not explicitly specified otherwise.

DETAILED DESCRIPTION OF THE EMBODIMENTS

In the following description, reference is made to the accompanying figures, which form part of the disclosure, and which show, by way of illustration, specific aspects of embodiments of the application or specific aspects in which embodiments of the present application may be used. It is understood that embodiments of the application may be used in other aspects and comprise structural or logical changes not depicted in the figures. The following detailed description, therefore, is not to be taken in a limiting sense, and the scope of the present application is defined by the appended claims.

For instance, it is understood that a disclosure in connection with a described method may also hold true for a corresponding device or system configured to perform the method and vice versa. For example, if one or a plurality of specific method steps are described, a corresponding device may include one or a plurality of units, e.g. functional units, to perform the described one or plurality of method steps (e.g. one unit performing the one or plurality of steps, or a plurality of units each performing one or more of the plurality of steps), even if such one or more units are not explicitly described or illustrated in the figures. On the other hand, for example, if a specific apparatus is described based on one or a plurality of units, e.g. functional units, a corresponding method may include one step to perform the functionality of the one or plurality of units (e.g. one step performing the functionality of the one or plurality of units, or a plurality of steps each performing the functionality of one or more of the plurality of units), even if such one or plurality of steps are not explicitly described or illustrated in the figures. Further, it is understood that the features of the various exemplary embodiments and/or aspects described herein may be combined with each other, unless specifically noted otherwise.

Video coding typically refers to the processing of a sequence of pictures, which form the video or video sequence. Instead of the term “picture” the term “frame” or “image” may be used as synonyms in the field of video coding. Video coding (or coding in general) comprises two parts video encoding and video decoding. Video encoding is performed at the source side, typically comprising processing (e.g. by compression) the original video pictures to reduce the amount of data required for representing the video pictures (for more efficient storage and/or transmission). Video decoding is performed at the destination side and typically comprises the inverse processing compared to the encoder to reconstruct the video pictures. Embodiments referring to “coding” of video pictures (or pictures in general) shall be understood to relate to “encoding” or “decoding” of video pictures or respective video sequences. The combination of the encoding part and the decoding part is also referred to as CODEC (Coding and Decoding).

In case of lossless video coding, the original video pictures might be reconstructed, i.e. the reconstructed video pictures have the same quality as the original video pictures (assuming no transmission loss or other data loss during storage or transmission). In case of lossy video coding, further compression, e.g. by quantization, is performed, to reduce the amount of data representing the video pictures, which cannot be completely reconstructed at the decoder, i.e. the quality of the reconstructed video pictures is lower or worse compared to the quality of the original video pictures.

Several video coding standards belong to the group of “lossy hybrid video codecs” (i.e. combine spatial and temporal prediction in the sample domain and 2D transform coding for applying quantization in the transform domain). Each picture of a video sequence is typically partitioned into a set of non-overlapping blocks and the coding is typically performed on a block level. In other words, at the encoder the video is typically processed, i.e. encoded, on a block (video block) level, e.g. by using spatial (intra picture) prediction and/or temporal (inter picture) prediction to generate a prediction block, subtracting the prediction block from the current block (block currently processed/to be processed) to obtain a residual block, transforming the residual block and quantizing the residual block in the transform domain to reduce the amount of data to be transmitted (compression), whereas at the decoder the inverse processing compared to the encoder is applied to the encoded or compressed block to reconstruct the current block for representation. Furthermore, the encoder duplicates the decoder processing loop such that both will generate identical predictions (e.g. intra- and inter predictions) and/or re-constructions for processing, i.e. coding, the subsequent blocks. In the following embodiments of a video coding system 10, a video encoder 20 and a video decoder 30 are described based on FIGS. 1 to 3.

FIG. 1A is a schematic block diagram illustrating an example coding system 10, e.g. a video coding system 10 (or short coding system 10) that may utilize techniques of this present application. Video encoder 20 (or short encoder 20) and video decoder 30 (or short decoder 30) of video coding system 10 represent examples of devices that may be configured to perform techniques in accordance with various examples described in the present application. As shown in FIG. 1A, the coding system 10 comprises a source device 12 configured to provide encoded picture data 21 e.g. to a destination device 14 for decoding the encoded picture data 13.

The source device 12 comprises an encoder 20, and may additionally, i.e. optionally, comprise a picture source 16, a pre-processor (or pre-processing unit) 18, e.g. a picture pre-processor 18, and a communication interface or communication unit 22.

The picture source 16 may comprise or be any kind of picture capturing device, for example a camera for capturing a real-world picture, and/or any kind of a picture generating device, for example a computer-graphics processor for generating a computer animated picture, or any kind of other device for obtaining and/or providing a real-world picture, a computer generated picture (e.g. a screen content, a virtual reality (VR) picture) and/or any combination thereof (e.g. an augmented reality (AR) picture). The picture source may be any kind of memory or storage storing any of the aforementioned pictures.

In distinction to the pre-processor 18 and the processing performed by the pre-processing unit 18, the picture or picture data 17 may also be referred to as raw picture or raw picture data 17.

Pre-processor 18 is configured to receive the (raw) picture data 17 and to perform pre-processing on the picture data 17 to obtain a pre-processed picture 19 or pre-processed picture data 19. Pre-processing performed by the pre-processor 18 may, e.g., comprise trimming, color format conversion (e.g. from RGB to YCbCr), color correction, or de-noising. It might be understood that the pre-processing unit 18 may be optional component. The video encoder 20 is configured to receive the pre-processed picture data 19 and provide encoded picture data 21 (further details will be described below, e.g., based on FIG. 2). Communication interface 22 of the source device 12 may be configured to receive the encoded picture data 21 and to transmit the encoded picture data 21 (or any further processed version thereof) over communication channel 13 to another device, e.g. the destination device 14 or any other device, for storage or direct reconstruction.

The destination device 14 comprises a decoder 30 (e.g. a video decoder 30), and may additionally, i.e. optionally, comprise a communication interface or communication unit 28, a post-processor 32 (or post-processing unit 32) and a display device 34.

The communication interface 28 of the destination device 14 is configured receive the encoded picture data 21 (or any further processed version thereof), e.g. directly from the source device 12 or from any other source, e.g. a storage device, e.g. an encoded picture data storage device, and provide the encoded picture data 21 to the decoder 30.

The communication interface 22 and the communication interface 28 may be configured to transmit or receive the encoded picture data 21 or encoded data 13 via a direct communication link between the source device 12 and the destination device 14, e.g. a direct wired or wireless connection, or via any kind of network, e.g. a wired or wireless network or any combination thereof, or any kind of private and public network, or any kind of combination thereof.

The communication interface 22 may be, e.g., configured to package the encoded picture data 21 into an appropriate format, e.g. packets, and/or process the encoded picture data using any kind of transmission encoding or processing for transmission over a communication link or communication network.

The communication interface 28, forming the counterpart of the communication interface 22, may be, e.g., configured to receive the transmitted data and process the transmission data using any kind of corresponding transmission decoding or processing and/or de-packaging to obtain the encoded picture data 21.

Both, communication interface 22 and communication interface 28 may be configured as unidirectional communication interfaces as indicated by the arrow for the communication channel 13 in FIG. 1A pointing from the source device 12 to the destination device 14, or bi-directional communication interfaces, and may be configured, e.g. to send and receive messages, e.g. to set up a connection, to acknowledge and exchange any other information related to the communication link and/or data transmission, e.g. encoded picture data transmission.

The decoder 30 is configured to receive the encoded picture data 21 and provide decoded picture data 31 or a decoded picture 31 (further details will be described below, e.g., based on FIG. 3 or FIG. 5).

The post-processor 32 of destination device 14 is configured to post-process the decoded picture data 31 (also called reconstructed picture data), e.g. the decoded picture 31, to obtain post-processed picture data 33, e.g. a post-processed picture 33. The post-processing performed by the post-processing unit 32 may comprise, e.g. color format conversion (e.g. from YCbCr to RGB), color correction, trimming, or re-sampling, or any other processing, e.g. for preparing the decoded picture data 31 for display, e.g. by display device 34.

The display device 34 of the destination device 14 is configured to receive the post-processed picture data 33 for displaying the picture, e.g. to a user or viewer. The display device 34 may be or comprise any kind of display for representing the reconstructed picture, e.g. an integrated or external display or monitor. The displays may, e.g. comprise liquid crystal displays (LCD), organic light emitting diodes (OLED) displays, plasma displays, projectors, micro LED displays, liquid crystal on silicon (LCoS), digital light processor (DLP) or any kind of other display.

Although FIG. 1A depicts the source device 12 and the destination device 14 as separate devices, embodiments of devices may also comprise both or both functionalities, the source device 12 or corresponding functionality and the destination device 14 or corresponding functionality. In such embodiments the source device 12 or corresponding functionality and the destination device 14 or corresponding functionality may be implemented using the same hardware and/or software or by separate hardware and/or software or any combination thereof.

As will be apparent for the skilled person based on the description, the existence and (exact) split of functionalities of the different units or functionalities within the source device 12 and/or destination device 14 as shown in FIG. 1A may vary depending on the actual device and application.

The encoder 20 (e.g. a video encoder 20) or the decoder 30 (e.g. a video decoder 30) or both encoder 20 and decoder 30 may be implemented via processing circuitry as shown in FIG. 1B, such as one or more microprocessors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), discrete logic, hardware, video coding dedicated or any combinations thereof. The encoder 20 may be implemented via processing circuitry 46 to embody the various modules as discussed with respect to encoder 20 of FIG. 2 and/or any other encoder system or subsystem described herein. The decoder 30 may be implemented via processing circuitry 46 to embody the various modules as discussed with respect to decoder 30 of FIG. 3 and/or any other decoder system or subsystem described herein. The processing circuitry may be configured to perform the various operations as discussed later. As shown in FIG. 5, if the techniques are implemented partially in software, a device may store instructions for the software in a suitable, non-transitory computer-readable storage medium and may execute the instructions in hardware using one or more processors to perform the techniques of this disclosure. Either of video encoder 20 and video decoder 30 may be integrated as part of a combined encoder/decoder (CODEC) in a single device, for example, as shown in FIG. 1B.

Source device 12 and destination device 14 may comprise any of a wide range of devices, including any kind of handheld or stationary devices, e.g. notebook or laptop computers, mobile phones, smart phones, tablets or tablet computers, cameras, desktop computers, set-top boxes, televisions, display devices, digital media players, video gaming consoles, video streaming devices (such as content services servers or content delivery servers), broadcast receiver device, broadcast transmitter device, or the like and may use no or any kind of operating system. In some cases, the source device 12 and the destination device 14 may be equipped for wireless communication. Thus, the source device 12 and the destination device 14 may be wireless communication devices.

In some cases, video coding system 10 illustrated in FIG. 1A is merely an example and the techniques of the present application may apply to video coding settings (e.g., video encoding or video decoding) that do not necessarily include any data communication between the encoding and decoding devices. In other examples, data is retrieved from a local memory, streamed over a network, or the like. A video encoding device may encode and store data to memory, and/or a video decoding device may retrieve and decode data from memory. In some examples, the encoding and decoding is performed by devices that do not communicate with one another, but simply encode data to memory and/or retrieve and decode data from memory.

For convenience of description, embodiments of the application are described herein, for example, by reference to High-Efficiency Video Coding (HEVC) or to the reference software of Versatile Video coding (VVC), the next generation video coding standard developed by the Joint Collaboration Team on Video Coding (JCT-VC) of ITU-T Video Coding Experts Group (VCEG) and ISO/IEC Motion Picture Experts Group (MPEG). One of ordinary skill in the art will understand that embodiments of the application are not limited to HEVC or VVC.

Encoder and Encoding Method

FIG. 2 shows a schematic block diagram of an example video encoder 20 that is configured to implement the techniques of the present application. In the example of FIG. 2, the video encoder 20 comprises an input 201 (or input interface 201), a residual calculation unit 204, a transform processing unit 206, a quantization unit 208, an inverse quantization unit 210, and inverse transform processing unit 212, a reconstruction unit 214, a loop filter unit 220, a decoded picture buffer (DPB) 230, a mode selection unit 260, an entropy encoding unit 270 and an output 272 (or output interface 272). The mode selection unit 260 may include an inter prediction unit 244, an intra prediction unit 254 and a partitioning unit 262. Inter prediction unit 244 may include a motion estimation unit and a motion compensation unit (not shown). A video encoder 20 as shown in FIG. 2 may also be referred to as hybrid video encoder or a video encoder according to a hybrid video codec.

The residual calculation unit 204, the transform processing unit 206, the quantization unit 208, the mode selection unit 260 may be referred to as forming a forward signal path of the encoder 20, whereas the inverse quantization unit 210, the inverse transform processing unit 212, the reconstruction unit 214, the buffer 216, the loop filter 220, the decoded picture buffer (DPB) 230, the inter prediction unit 244 and the intra-prediction unit 254 may be referred to as forming a backward signal path of the video encoder 20, wherein the backward signal path of the video encoder 20 corresponds to the signal path of the decoder (see video decoder 30 in FIG. 3). The inverse quantization unit 210, the inverse transform processing unit 212, the reconstruction unit 214, the loop filter 220, the decoded picture buffer (DPB) 230, the inter prediction unit 244 and the intra-prediction unit 254 are also referred to forming the “built-in decoder” of video encoder 20.

Pictures & Picture Partitioning (Pictures & Blocks) The encoder 20 may be configured to receive, e.g. via input 201, a picture 17 (or picture data 17), e.g. picture of a sequence of pictures forming a video or video sequence. The received picture or picture data may also be a pre-processed picture 19 (or pre-processed picture data 19). For sake of simplicity the following description refers to the picture 17. The picture 17 may also be referred to as current picture or picture to be coded (in particular in video coding to distinguish the current picture from other pictures, e.g. previously encoded and/or decoded pictures of the same video sequence, i.e. the video sequence which also comprises the current picture).

A (digital) picture is or might be regarded as a two-dimensional array or matrix of samples with intensity values. A sample in the array may also be referred to as pixel (short form of picture element) or a pel. The number of samples in horizontal and vertical direction (or axis) of the array or picture define the size and/or resolution of the picture. For representation of color, typically three color components are employed, i.e. the picture may be represented or include three sample arrays. In RBG format or color space a picture comprises a corresponding red, green and blue sample array. However, in video coding each pixel is typically represented in a luminance and chrominance format or color space, e.g. YCbCr, which comprises a luminance component indicated by Y (sometimes also L is used instead) and two chrominance components indicated by Cb and Cr. The luminance (or short luma) component Y represents the brightness or grey level intensity (e.g. like in a grey-scale picture), while the two chrominance (or short chroma) components Cb and Cr represent the chromaticity or color information components. Accordingly, a picture in YCbCr format comprises a luminance sample array of luminance sample values (Y), and two chrominance sample arrays of chrominance values (Cb and Cr). Pictures in RGB format may be converted or transformed into YCbCr format and vice versa, the process is also known as color transformation or conversion. If a picture is monochrome, the picture may comprise only a luminance sample array. Accordingly, a picture may be, for example, an array of luma samples in monochrome format or an array of luma samples and two corresponding arrays of chroma samples in 4:2:0, 4:2:2, and 4:4:4 colour format.

Embodiments of the video encoder 20 may comprise a picture partitioning unit (not depicted in FIG. 2) configured to partition the picture 17 into a plurality of (typically non-overlapping) picture blocks 203. These blocks may also be referred to as root blocks, macro blocks (H.264/AVC) or coding tree blocks (CTB) or coding tree units (CTU) (H.265/HEVC and VVC). The picture partitioning unit may be configured to use the same block size for all pictures of a video sequence and the corresponding grid defining the block size, or to change the block size between pictures or subsets or groups of pictures, and partition each picture into the corresponding blocks.

In further embodiments, the video encoder may be configured to receive directly a block 203 of the picture 17, e.g. one, several or all blocks forming the picture 17. The picture block 203 may also be referred to as current picture block or picture block to be coded.

Like the picture 17, the picture block 203 again is or might be regarded as a two-dimensional array or matrix of samples with intensity values (sample values), although of smaller dimension than the picture 17. In other words, the block 203 may comprise, e.g., one sample array (e.g. a luma array in case of a monochrome picture 17, or a luma or chroma array in case of a color picture) or three sample arrays (e.g. a luma and two chroma arrays in case of a color picture 17) or any other number and/or kind of arrays depending on the color format applied. The number of samples in horizontal and vertical direction (or axis) of the block 203 define the size of block 203. Accordingly, a block may, for example, an M×N (M-column by N-row) array of samples, or an M×N array of transform coefficients.

Embodiments of the video encoder 20 as shown in FIG. 2 may be configured to encode the picture 17 block by block, e.g. the encoding and prediction is performed per block 203. Embodiments of the video encoder 20 as shown in FIG. 2 may be further configured to partition and/or encode the picture by using slices (also referred to as video slices), wherein a picture may be partitioned into or encoded using one or more slices (typically non-overlapping), and each slice may comprise one or more blocks (e.g. CTUs) or one or more groups of blocks (e.g. tiles (H.265/HEVC and VVC) or bricks (VVC)).

Embodiments of the video encoder 20 as shown in FIG. 2 may be further configured to partition and/or encode the picture by using slices/tile groups (also referred to as video tile groups) and/or tiles (also referred to as video tiles), wherein a picture may be partitioned into or encoded using one or more slices/tile groups (typically non-overlapping), and each slice/tile group may comprise, e.g. one or more blocks (e.g. CTUs) or one or more tiles, wherein each tile, e.g. may be of rectangular shape and may comprise one or more blocks (e.g. CTUs), e.g. complete or fractional blocks.

Residual Calculation

The residual calculation unit 204 may be configured to calculate a residual block 205 (also referred to as residual 205) based on the picture block 203 and a prediction block 265 (further details about the prediction block 265 are provided later), e.g. by subtracting sample values of the prediction block 265 from sample values of the picture block 203, sample by sample (pixel by pixel) to obtain the residual block 205 in the sample domain.

Transform

The transform processing unit 206 may be configured to apply a transform, e.g. a discrete cosine transform (DCT) or discrete sine transform (DST), on the sample values of the residual block 205 to obtain transform coefficients 207 in a transform domain. The transform coefficients 207 may also be referred to as transform residual coefficients and represent the residual block 205 in the transform domain.

The transform processing unit 206 may be configured to apply integer approximations of DCT/DST, such as the transforms specified for H.265/HEVC. Compared to an orthogonal DCT transform, such integer approximations are typically scaled by a certain factor. In order to preserve the norm of the residual block which is processed by forward and inverse transforms, additional scaling factors are applied as part of the transform process. The scaling factors are typically chosen based on certain constraints like scaling factors being a power of two for shift operations, bit depth of the transform coefficients, tradeoff between accuracy and implementation costs, etc. Specific scaling factors are, for example, specified for the inverse transform, e.g. by inverse transform processing unit 212 (and the corresponding inverse transform, e.g. by inverse transform processing unit 312 at video decoder 30) and corresponding scaling factors for the forward transform, e.g. by transform processing unit 206, at an encoder 20 may be specified accordingly.

Embodiments of the video encoder 20 (respectively transform processing unit 206) may be configured to output transform parameters, e.g. a type of transform or transforms, e.g. directly or encoded or compressed via the entropy encoding unit 270, so that, e.g., the video decoder 30 may receive and use the transform parameters for decoding.

Quantization

The quantization unit 208 may be configured to quantize the transform coefficients 207 to obtain quantized coefficients 209, e.g. by applying scalar quantization or vector quantization. The quantized coefficients 209 may also be referred to as quantized transform coefficients 209 or quantized residual coefficients 209.

The quantization process may reduce the bit depth associated with some or all of the transform coefficients 207. For example, an n-bit transform coefficient may be rounded down to an m-bit Transform coefficient during quantization, where n is greater than m. The degree of quantization may be modified by adjusting a quantization parameter (QP). For example for scalar quantization, different scaling may be applied to achieve finer or coarser quantization. Smaller quantization step sizes correspond to finer quantization, whereas larger quantization step sizes correspond to coarser quantization. The applicable quantization step size may be indicated by a quantization parameter (QP). The quantization parameter may for example be an index to a predefined set of applicable quantization step sizes. For example, small quantization parameters may correspond to fine quantization (small quantization step sizes) and large quantization parameters may correspond to coarse quantization (large quantization step sizes) or vice versa. The quantization may include division by a quantization step size and a corresponding and/or the inverse dequantization, e.g. by inverse quantization unit 210, may include multiplication by the quantization step size. Embodiments according to some standards, e.g. HEVC, may be configured to use a quantization parameter to determine the quantization step size. Generally, the quantization step size may be calculated based on a quantization parameter using a fixed point approximation of an equation including division. Additional scaling factors may be introduced for quantization and dequantization to restore the norm of the residual block, which might get modified because of the scaling used in the fixed point approximation of the equation for quantization step size and quantization parameter. In one example implementation, the scaling of the inverse transform and dequantization might be combined. Alternatively, customized quantization tables may be used and signaled from an encoder to a decoder, e.g. in a bitstream. The quantization is a lossy operation, wherein the loss increases with increasing quantization step sizes. Embodiments of the video encoder 20 (respectively quantization unit 208) may be configured to output quantization parameters (QP), e.g. directly or encoded via the entropy encoding unit 270, so that, e.g., the video decoder 30 may receive and apply the quantization parameters for decoding.

Inverse Quantization

The inverse quantization unit 210 is configured to apply the inverse quantization of the quantization unit 208 on the quantized coefficients to obtain dequantized coefficients 211, e.g. by applying the inverse of the quantization scheme applied by the quantization unit 208 based on or using the same quantization step size as the quantization unit 208. The dequantized coefficients 211 may also be referred to as dequantized residual coefficients 211 and correspond—although typically not identical to the transform coefficients due to the loss by quantization—to the transform coefficients 207.

Inverse Transform

The inverse transform processing unit 212 is configured to apply the inverse transform of the transform applied by the transform processing unit 206, e.g. an inverse discrete cosine transform (DCT) or inverse discrete sine transform (DST) or other inverse transforms, to obtain a reconstructed residual block 213 (or corresponding dequantized coefficients 213) in the sample domain. The reconstructed residual block 213 may also be referred to as transform block 213.

Reconstruction

The reconstruction unit 214 (e.g. adder or summer 214) is configured to add the transform block 213 (i.e. reconstructed residual block 213) to the prediction block 265 to obtain a reconstructed block 215 in the sample domain, e.g. by adding sample by sample—the sample values of the reconstructed residual block 213 and the sample values of the prediction block 265.

Filtering

The loop filter unit 220 (or short “loop filter” 220), is configured to filter the reconstructed block 215 to obtain a filtered block 221, or in general, to filter reconstructed samples to obtain filtered sample values. The loop filter unit is, e.g., configured to smooth pixel transitions, or otherwise improve the video quality. The loop filter unit 220 may comprise one or more loop filters such as a de-blocking filter, a sample-adaptive offset (SAO) filter or one or more other filters, e.g. an adaptive loop filter (ALF), a noise suppression filter (NSF), or any combination thereof. In an example, the loop filter unit 220 may comprise a de-blocking filter, a SAO filter and an ALF filter. The order of the filtering process may be the deblocking filter, SAO and ALF. In another example, a process called the luma mapping with chroma scaling (LMCS) (namely, the adaptive in-loop reshaper) is added. This process is performed before deblocking. In another example, the deblocking filter process may be also applied to internal sub-block edges, e.g. affine sub-blocks edges, ATMVP sub-blocks edges, sub-block transform (SBT) edges and intra sub-partition (ISP) edges. Although the loop filter unit 220 is shown in FIG. 2 as being an in loop filter, in other configurations, the loop filter unit 220 may be implemented as a post loop filter. The filtered block 221 may also be referred to as filtered reconstructed block 221.

Embodiments of the video encoder 20 (respectively loop filter unit 220) may be configured to output loop filter parameters (such as SAO filter parameters or ALF filter parameters or LMCS parameters), e.g. directly or encoded via the entropy encoding unit 270, so that, e.g., a decoder 30 may receive and apply the same loop filter parameters or respective loop filters for decoding.

Decoded Picture Buffer

The decoded picture buffer (DPB) 230 may be a memory that stores reference pictures, or in general reference picture data, for encoding video data by video encoder 20. The DPB 230 may be formed by any of a variety of memory devices, such as dynamic random access memory (DRAM), including synchronous DRAM (SDRAM), magnetoresistive RAM (MRAM), resistive RAM (RRAM), or other types of memory devices. The decoded picture buffer (DPB) 230 may be configured to store one or more filtered blocks 221. The decoded picture buffer 230 may be further configured to store other previously filtered blocks, e.g. previously reconstructed and filtered blocks 221, of the same current picture or of different pictures, e.g. previously reconstructed pictures, and may provide complete previously reconstructed, i.e. decoded, pictures (and corresponding reference blocks and samples) and/or a partially reconstructed current picture (and corresponding reference blocks and samples), for example for inter prediction. The decoded picture buffer (DPB) 230 may be also configured to store one or more unfiltered reconstructed blocks 215, or in general unfiltered reconstructed samples, e.g. if the reconstructed block 215 is not filtered by loop filter unit 220, or any other further processed version of the reconstructed blocks or samples.

Mode Selection (Partitioning & Prediction)

The mode selection unit 260 comprises partitioning unit 262, inter-prediction unit 244 and intra-prediction unit 254, and is configured to receive or obtain original picture data, e.g. an original block 203 (current block 203 of the current picture 17), and reconstructed picture data, e.g. filtered and/or unfiltered reconstructed samples or blocks of the same (current) picture and/or from one or a plurality of previously decoded pictures, e.g. from decoded picture buffer 230 or other buffers (e.g. line buffer, not shown). The reconstructed picture data is used as reference picture data for prediction, e.g. inter-prediction or intra-prediction, to obtain a prediction block 265 or predictor 265.

Mode selection unit 260 may be configured to determine or select a partitioning for a current block prediction mode (including no partitioning) and a prediction mode (e.g. an intra or inter prediction mode) and generate a corresponding prediction block 265, which is used for the calculation of the residual block 205 and for the reconstruction of the reconstructed block 215.

Embodiments of the mode selection unit 260 may be configured to select the partitioning and the prediction mode (e.g. from those supported by or available for mode selection unit 260), which provide the best match or in other words the minimum residual (minimum residual means better compression for transmission or storage), or a minimum signaling overhead (minimum signaling overhead means better compression for transmission or storage), or which considers or balances both. The mode selection unit 260 may be configured to determine the partitioning and prediction mode based on rate distortion optimization (RDO), i.e. select the prediction mode which provides a minimum rate distortion. Terms like “best”, “minimum”, “optimum” etc. in this context do not necessarily refer to an overall “best”, “minimum”, “optimum”, etc. but may also refer to the fulfillment of a termination or selection criterion like a value exceeding or falling below a threshold or other constraints leading potentially to a “sub-optimum selection” but reducing complexity and processing time.

In other words, the partitioning unit 262 may be configured to partition a picture from a video sequence into a sequence of coding tree units (CTUs), and the CTU 203 may be further partitioned into smaller block partitions or sub-blocks (which form again blocks), e.g. iteratively using quad-tree-partitioning (QT), binary partitioning (BT) or triple-tree-partitioning (TT) or any combination thereof, and to perform, e.g., the prediction for each of the block partitions or sub-blocks, wherein the mode selection comprises the selection of the tree-structure of the partitioned block 203 and the prediction modes are applied to each of the block partitions or sub-blocks.

In the following the partitioning (e.g. by partitioning unit 260) and prediction processing (by inter-prediction unit 244 and intra-prediction unit 254) performed by an example video encoder 20 will be explained in more detail.

Partitioning

The partitioning unit 262 may be configured to partition a picture from a video sequence into a sequence of coding tree units (CTUs), and the partitioning unit 262 may partition (or split) a coding tree unit (CTU) 203 into smaller partitions, e.g. smaller blocks of square or rectangular size. For a picture that has three sample arrays, a CTU consists of an N×N block of luma samples together with two corresponding blocks of chroma samples. The maximum allowed size of the luma block in a CTU is specified to be 128×128 in the developing versatile video coding (VVC), but it might be specified to be value rather than 128×128 in the future, for example, 256×256. The CTUs of a picture may be clustered/grouped as slices/tile groups, tiles or bricks. A tile covers a rectangular region of a picture, and a tile might be divided into one or more bricks. A brick consists of a number of CTU rows within a tile. A tile that is not partitioned into multiple bricks might be referred to as a brick. However, a brick is a true subset of a tile and is not referred to as a tile. There are two modes of tile groups are supported in VVC, namely the raster-scan slice/tile group mode and the rectangular slice mode. In the raster-scan tile group mode, a slice/tile group contains a sequence of tiles in tile raster scan of a picture. In the rectangular slice mode, a slice contains a number of bricks of a picture that collectively form a rectangular region of the picture. The bricks within a rectangular slice are in the order of brick raster scan of the slice. These smaller blocks (which may also be referred to as sub-blocks) may be further partitioned into even smaller partitions. This is also referred to tree-partitioning or hierarchical tree-partitioning, wherein a root block, e.g. at root tree-level 0 (hierarchy-level 0, depth 0), may be recursively partitioned, e.g. partitioned into two or more blocks of a next lower tree-level, e.g. nodes at tree-level 1 (hierarchy-level 1, depth 1), wherein these blocks may be again partitioned into two or more blocks of a next lower level, e.g. tree-level 2 (hierarchy-level 2, depth 2), etc. until the partitioning is terminated, e.g. because a termination criterion is fulfilled, e.g. a maximum tree depth or minimum block size is reached. Blocks which are not further partitioned are also referred to as leaf-blocks or leaf nodes of the tree. A tree using partitioning into two partitions is referred to as binary-tree (BT), a tree using partitioning into three partitions is referred to as ternary-tree (TT), and a tree using partitioning into four partitions is referred to as quad-tree (QT).

For example, a coding tree unit (CTU) may be or comprise a CTB of luma samples, two corresponding CTBs of chroma samples of a picture that has three sample arrays, or a CTB of samples of a monochrome picture or a picture that is coded using three separate colour planes and syntax structures used to code the samples. Correspondingly, a coding tree block (CTB) may be an N×N block of samples for some value of N such that the division of a component into CTBs is a partitioning. A coding unit (CU) may be or comprise a coding block of luma samples, two corresponding coding blocks of chroma samples of a picture that has three sample arrays, or a coding block of samples of a monochrome picture or a picture that is coded using three separate colour planes and syntax structures used to code the samples. Correspondingly a coding block (CB) may be an M×N block of samples for some values of M and N such that the division of a CTB into coding blocks is a partitioning.

In embodiments, e.g., according to HEVC, a coding tree unit (CTU) may be split into CUs by using a quad-tree structure denoted as coding tree. The decision whether to code a picture area using inter-picture (temporal) or intra-picture (spatial) prediction is made at the leaf CU level. Each leaf CU might be further split into one, two or four PUs according to the PU splitting type. Inside one PU, the same prediction process is applied and the relevant information is transmitted to the decoder on a PU basis. After obtaining the residual block by applying the prediction process based on the PU splitting type, a leaf CU might be partitioned into transform units (TUs) according to another quadtree structure similar to the coding tree for the CU.

In embodiments, e.g., according to the latest video coding standard currently in development, which is referred to as Versatile Video Coding (VVC), a combined Quad-tree nested multi-type tree using binary and ternary splits segmentation structure, for example used to partition a coding tree unit. In the coding tree structure within a coding tree unit, a CU can have either a square or rectangular shape. For example, the coding tree unit (CTU) is first partitioned by a quaternary tree. Then the quaternary tree leaf nodes might be further partitioned by a multi-type tree structure. There are four splitting types in multi-type tree structure, vertical binary splitting (SPLIT_BT_VER), horizontal binary splitting (SPLIT_BTHOR), vertical ternary splitting (SPLIT_TT_VER), and horizontal ternary splitting (SPLIT_TT_HOR). The multi-type tree leaf nodes are called coding units (CUs), and unless the CU is too large for the maximum transform length, this segmentation is used for prediction and transform processing without any further partitioning. This means that, in most cases, the CU, PU and TU have the same block size in the quadtree with nested multi-type tree coding block structure. The exception occurs when maximum supported transform length is smaller than the width or height of the colour component of the CU.VVC develops a unique signaling mechanism of the partition splitting information in quadtree with nested multi-type tree coding tree structure. In the signaling mechanism, a coding tree unit (CTU) is treated as the root of a quaternary tree and is first partitioned by a quaternary tree structure. Each quaternary tree leaf node (when sufficiently large to allow it) is then further partitioned by a multi-type tree structure. In the multi-type tree structure, a first flag (mtt_split_cu_flag) is signaled to indicate whether the node is further partitioned; when a node is further partitioned, a second flag (mtt_split_cu_vertical_flag) is signaled to indicate the splitting direction, and then a third flag (mtt_split_cu_binary_flag) is signaled to indicate whether the split is a binary split or a ternary split. Based on the values of mtt_split_cu_vertical_flag and mtt_split_cu_binary_flag, the multi-type tree slitting mode (MttSplitMode) of a CU might be derived by a decoder based on a predefined rule or a table. It should be noted, for a certain design, for example, 64×64 Luma block and 32×32 Chroma pipelining design in VVC hardware decoders, TT split is forbidden when either width or height of a luma coding block is larger than 64, as shown in FIG. 6. TT split is also forbidden when either width or height of a chroma coding block is larger than 32. The pipelining design will divide a picture into Virtual pipeline data units (VPDUs) which are defined as non-overlapping units in a picture. In hardware decoders, successive VPDUs are processed by multiple pipeline stages simultaneously. The VPDU size is roughly proportional to the buffer size in most pipeline stages, so it is important to keep the VPDU size small. In most hardware decoders, the VPDU size might be set to maximum transform block (TB) size. However, in VVC, ternary tree (TT) and binary tree (BT) partition may lead to the increasing of VPDUs sizes.

In addition, it should be noted that, when a portion of a tree node block exceeds the bottom or right picture boundary, the tree node block is forced to be split until the all samples of every coded CU are located inside the picture boundaries.

As an example, the Intra Sub-Partitions (ISP) tool may divide luma intra-predicted blocks vertically or horizontally into 2 or 4 sub-partitions depending on the block size.

In one example, the mode selection unit 260 of video encoder 20 may be configured to perform any combination of the partitioning techniques described herein.

As described above, the video encoder 20 is configured to determine or select the best or an optimum prediction mode from a set of (e.g. pre-determined) prediction modes. The set of prediction modes may comprise, e.g., intra-prediction modes and/or inter-prediction modes.

Intra-Prediction

The set of intra-prediction modes may comprise 35 different intra-prediction modes, e.g. non-directional modes like DC (or mean) mode and planar mode, or directional modes, e.g. as defined in HEVC, or may comprise 67 different intra-prediction modes, e.g. non-directional modes like DC (or mean) mode and planar mode, or directional modes, e.g. as defined for VVC. As an example, several conventional angular intra prediction modes are adaptively replaced with wide-angle intra prediction modes for the non-square blocks, e.g. as defined in VVC. As another example, to avoid division operations for DC prediction, only the longer side is used to compute the average for non-square blocks. And, the results of intra prediction of planar mode may be further modified by a position dependent intra prediction combination (PDPC) method.

The intra-prediction unit 254 is configured to use reconstructed samples of neighboring blocks of the same current picture to generate an intra-prediction block 265 according to an intra-prediction mode of the set of intra-prediction modes.

The intra prediction unit 254 (or in general the mode selection unit 260) is further configured to output intra-prediction parameters (or in general information indicative of the selected intra prediction mode for the block) to the entropy encoding unit 270 in form of syntax elements 266 for inclusion into the encoded picture data 21, so that, e.g., the video decoder 30 may receive and use the prediction parameters for decoding.

Inter-Prediction

The set of (or possible) inter-prediction modes depends on the available reference pictures (i.e. previous at least partially decoded pictures, e.g. stored in DBP 230) and other inter-prediction parameters, e.g. whether the whole reference picture or only a part, e.g. a search window area around the area of the current block, of the reference picture is used for searching for a best matching reference block, and/or e.g. whether pixel interpolation is applied, e.g. half/semi-pel, quarter-pel and/or 1/16 pel interpolation, or not. Additional to the above prediction modes, skip mode, direct mode and/or other inter prediction mode may be applied.

For example, Extended merge prediction, the merge candidate list of such mode is constructed by including the following five types of candidates in order: Spatial MVP from spatial neighbor CUs, Temporal MVP from collocated CUs, History-based MVP from an FIFO table, Pairwise average MVP and Zero MVs. And a bilateral-matching based decoder side motion vector refinement (DMVR) may be applied to increase the accuracy of the MVs of the merge mode. Merge mode with MVD (MMVD), which comes from merge mode with motion vector differences. A MMVD flag is signaled right after sending a skip flag and merge flag to specify whether MMVD mode is used for a CU. And a CU-level adaptive motion vector resolution (AMVR) scheme may be applied. AMVR allows MVD of the CU to be coded in different precision. Dependent on the prediction mode for the current CU, the MVDs of the current CU might be adaptively selected. When a CU is coded in merge mode, the combined inter/intra prediction (CIIP) mode may be applied to the current CU. Weighted averaging of the inter and intra prediction signals is performed to obtain the CIIP prediction. Affine motion compensated prediction, the affine motion field of the block is described by motion information of two control point (4-parameter) or three control point motion vectors (6-parameter). Subblock-based temporal motion vector prediction (SbTMVP), which is similar to the temporal motion vector prediction (TMVP) in HEVC, but predicts the motion vectors of the sub-CUs within the current CU. Bi-directional optical flow (BDOF), previously referred to as BIO, is a simpler version that requires much less computation, especially in terms of number of multiplications and the size of the multiplier. Triangle partition mode, in such a mode, a CU is split evenly into two triangle-shaped partitions, using either the diagonal split or the anti-diagonal split. Besides, the bi-prediction mode is extended beyond simple averaging to allow weighted averaging of the two prediction signals.

The inter prediction unit 244 may include a motion estimation (ME) unit and a motion compensation (MC) unit (both not shown in FIG. 2). The motion estimation unit may be configured to receive or obtain the picture block 203 (current picture block 203 of the current picture 17) and a decoded picture 231, or at least one or a plurality of previously reconstructed blocks, e.g. reconstructed blocks of one or a plurality of other/different previously decoded pictures 231, for motion estimation. E.g. a video sequence may comprise the current picture and the previously decoded pictures 231, or in other words, the current picture and the previously decoded pictures 231 may be part of or form a sequence of pictures forming a video sequence.

The encoder 20 may, e.g., be configured to select a reference block from a plurality of reference blocks of the same or different pictures of the plurality of other pictures and provide a reference picture (or reference picture index) and/or an offset (spatial offset) between the position (x, y coordinates) of the reference block and the position of the current block as inter prediction parameters to the motion estimation unit. This offset is also called motion vector (MV).

The motion compensation unit is configured to obtain, e.g. receive, an inter prediction parameter and to perform inter prediction based on or using the inter prediction parameter to obtain an inter prediction block 265. Motion compensation, performed by the motion compensation unit, may involve fetching or generating the prediction block based on the motion/block vector determined by motion estimation, possibly performing interpolations to sub-pixel precision. Interpolation filtering may generate additional pixel samples from known pixel samples, thus potentially increasing the number of candidate prediction blocks that may be used to code a picture block. Upon receiving the motion vector for the PU of the current picture block, the motion compensation unit may locate the prediction block to which the motion vector points in one of the reference picture lists.

The motion compensation unit may also generate syntax elements associated with the blocks and video slices for use by video decoder 30 in decoding the picture blocks of the video slice. In addition or as an alternative to slices and respective syntax elements, tile groups and/or tiles and respective syntax elements may be generated or used.

Entropy Coding

The entropy encoding unit 270 is configured to apply, for example, an entropy encoding algorithm or scheme (e.g. a variable length coding (VLC) scheme, an context adaptive VLC scheme (CAVLC), an arithmetic coding scheme, a binarization, a context adaptive binary arithmetic coding (CABAC), syntax-based context-adaptive binary arithmetic coding (SBAC), probability interval partitioning entropy (PIPE) coding or another entropy encoding methodology or technique) or bypass (no compression) on the quantized coefficients 209, inter prediction parameters, intra prediction parameters, loop filter parameters and/or other syntax elements to obtain encoded picture data 21 which might be output via the output 272, e.g. in the form of an encoded bitstream 21, so that, e.g., the video decoder 30 may receive and use the parameters for decoding. The encoded bitstream 21 may be transmitted to video decoder 30, or stored in a memory for later transmission or retrieval by video decoder 30. Other structural variations of the video encoder 20 might be used to encode the video stream. For example, a non-transform based encoder 20 can quantize the residual signal directly without the transform processing unit 206 for certain blocks or frames. In another implementation, an encoder 20 can have the quantization unit 208 and the inverse quantization unit 210 combined into a single unit.

Decoder and Decoding Method

FIG. 3 shows an example of a video decoder 30 that is configured to implement the techniques of this present application. The video decoder 30 is configured to receive encoded picture data 21 (e.g. encoded bitstream 21), e.g. encoded by encoder 20, to obtain a decoded picture 331. The encoded picture data or bitstream comprises information for decoding the encoded picture data, e.g. data that represents picture blocks of an encoded video slice (and/or tile groups or tiles) and associated syntax elements.

In the example of FIG. 3, the decoder 30 comprises an entropy decoding unit 304, an inverse quantization unit 310, an inverse transform processing unit 312, a reconstruction unit 314 (e.g. a summer 314), a loop filter 320, a decoded picture buffer (DBP) 330, a mode application unit 360, an inter prediction unit 344 and an intra prediction unit 354. Inter prediction unit 344 may be or include a motion compensation unit. Video decoder 30 may, in some examples, perform a decoding pass generally reciprocal to the encoding pass described with respect to video encoder 100 from FIG. 2.

As explained with regard to the encoder 20, the inverse quantization unit 210, the inverse transform processing unit 212, the reconstruction unit 214, the loop filter 220, the decoded picture buffer (DPB) 230, the inter prediction unit 344 and the intra prediction unit 354 are also referred to as forming the “built-in decoder” of video encoder 20. Accordingly, the inverse quantization unit 310 may be identical in function to the inverse quantization unit 110, the inverse transform processing unit 312 may be identical in function to the inverse transform processing unit 212, the reconstruction unit 314 may be identical in function to reconstruction unit 214, the loop filter 320 may be identical in function to the loop filter 220, and the decoded picture buffer 330 may be identical in function to the decoded picture buffer 230. Therefore, the explanations provided for the respective units and functions of the video 20 encoder apply correspondingly to the respective units and functions of the video decoder 30.

Entropy Decoding

The entropy decoding unit 304 is configured to parse the bitstream 21 (or in general encoded picture data 21) and perform, for example, entropy decoding to the encoded picture data 21 to obtain, e.g., quantized coefficients 309 and/or decoded coding parameters (not shown in FIG. 3), e.g. any or all of inter prediction parameters (e.g. reference picture index and motion vector), intra prediction parameter (e.g. intra prediction mode or index), transform parameters, quantization parameters, loop filter parameters, and/or other syntax elements. Entropy decoding unit 304 maybe configured to apply the decoding algorithms or schemes corresponding to the encoding schemes as described with regard to the entropy encoding unit 270 of the encoder 20. Entropy decoding unit 304 may be further configured to provide inter prediction parameters, intra prediction parameter and/or other syntax elements to the mode application unit 360 and other parameters to other units of the decoder 30. Video decoder 30 may receive the syntax elements at the video slice level and/or the video block level. In addition or as an alternative to slices and respective syntax elements, tile groups and/or tiles and respective syntax elements may be received and/or used.

Inverse Quantization

The inverse quantization unit 310 may be configured to receive quantization parameters (QP) (or in general information related to the inverse quantization) and quantized coefficients from the encoded picture data 21 (e.g. by parsing and/or decoding, e.g. by entropy decoding unit 304) and to apply based on the quantization parameters an inverse quantization on the decoded quantized coefficients 309 to obtain dequantized coefficients 311, which may also be referred to as transform coefficients 311. The inverse quantization process may include use of a quantization parameter determined by video encoder 20 for each video block in the video slice (or tile or tile group) to determine a degree of quantization and, likewise, a degree of inverse quantization that should be applied.

Inverse Transform

Inverse transform processing unit 312 may be configured to receive dequantized coefficients 311, also referred to as transform coefficients 311, and to apply a transform to the dequantized coefficients 311 in order to obtain reconstructed residual blocks 213 in the sample domain. The reconstructed residual blocks 213 may also be referred to as transform blocks 313. The transform may be an inverse transform, e.g., an inverse DCT, an inverse DST, an inverse integer transform, or a conceptually similar inverse transform process. The inverse transform processing unit 312 may be further configured to receive transform parameters or corresponding information from the encoded picture data 21 (e.g. by parsing and/or decoding, e.g. by entropy decoding unit 304) to determine the transform to be applied to the dequantized coefficients 311.

Reconstruction

The reconstruction unit 314 (e.g. adder or summer 314) may be configured to add the reconstructed residual block 313, to the prediction block 365 to obtain a reconstructed block 315 in the sample domain, e.g. by adding the sample values of the reconstructed residual block 313 and the sample values of the prediction block 365.

Filtering

The loop filter unit 320 (either in the coding loop or after the coding loop) is configured to filter the reconstructed block 315 to obtain a filtered block 321, e.g. to smooth pixel transitions, or otherwise improve the video quality. The loop filter unit 320 may comprise one or more loop filters such as a de-blocking filter, a sample-adaptive offset (SAO) filter or one or more other filters, e.g. an adaptive loop filter (ALF), a noise suppression filter (NSF), or any combination thereof. In an example, the loop filter unit 220 may comprise a de-blocking filter, a SAO filter and an ALF filter. The order of the filtering process may be the deblocking filter, SAO and ALF. In another example, a process called the luma mapping with chroma scaling (LMCS) (namely, the adaptive in-loop reshaper) is added. This process is performed before deblocking. In another example, the deblocking filter process may be also applied to internal sub-block edges, e.g. affine sub-blocks edges, ATMVP sub-blocks edges, sub-block transform (SBT) edges and intra sub-partition (ISP) edges. Although the loop filter unit 320 is shown in FIG. 3 as being an in loop filter, in other configurations, the loop filter unit 320 may be implemented as a post loop filter.

Decoded Picture Buffer

The decoded video blocks 321 of a picture are then stored in decoded picture buffer 330, which stores the decoded pictures 331 as reference pictures for subsequent motion compensation for other pictures and/or for output respectively display.

The decoder 30 is configured to output the decoded picture 311, e.g. via output 312, for presentation or viewing to a user.

Prediction

The inter prediction unit 344 may be identical to the inter prediction unit 244 (in particular to the motion compensation unit) and the intra prediction unit 354 may be identical to the inter prediction unit 254 in function, and performs split or partitioning decisions and prediction based on the partitioning and/or prediction parameters or respective information received from the encoded picture data 21 (e.g. by parsing and/or decoding, e.g. by entropy decoding unit 304). Mode application unit 360 may be configured to perform the prediction (intra or inter prediction) per block based on reconstructed pictures, blocks or respective samples (filtered or unfiltered) to obtain the prediction block 365.

When the video slice is coded as an intra coded (I) slice, intra prediction unit 354 of mode application unit 360 is configured to generate prediction block 365 for a picture block of the current video slice based on a signaled intra prediction mode and data from previously decoded blocks of the current picture. When the video picture is coded as an inter coded (i.e., B, or P) slice, inter prediction unit 344 (e.g. motion compensation unit) of mode application unit 360 is configured to produce prediction blocks 365 for a video block of the current video slice based on the motion vectors and other syntax elements received from entropy decoding unit 304. For inter prediction, the prediction blocks may be produced from one of the reference pictures within one of the reference picture lists. Video decoder 30 may construct the reference frame lists, List 0 and List 1, using default construction techniques based on reference pictures stored in DPB 330. The same or similar may be applied for or by embodiments using tile groups (e.g. video tile groups) and/or tiles (e.g. video tiles) in addition or alternatively to slices (e.g. video slices), e.g. a video may be coded using I, P or B tile groups and/or tiles.

Mode application unit 360 is configured to determine the prediction information for a video block of the current video slice by parsing the motion vectors or related information and other syntax elements, and uses the prediction information to produce the prediction blocks for the current video block being decoded. For example, the mode application unit 360 uses some of the received syntax elements to determine a prediction mode (e.g., intra or inter prediction) used to code the video blocks of the video slice, an inter prediction slice type (e.g., B slice, P slice, or GPB slice), construction information for one or more of the reference picture lists for the slice, motion vectors for each inter encoded video block of the slice, inter prediction status for each inter coded video block of the slice, and other information to decode the video blocks in the current video slice. The same or similar may be applied for or by embodiments using tile groups (e.g. video tile groups) and/or tiles (e.g. video tiles) in addition or alternatively to slices (e.g. video slices), e.g. a video may be coded using I, P or B tile groups and/or tiles.

Embodiments of the video decoder 30 as shown in FIG. 3 may be configured to partition and/or decode the picture by using slices (also referred to as video slices), wherein a picture may be partitioned into or decoded using one or more slices (typically non-overlapping), and each slice may comprise one or more blocks (e.g. CTUs) or one or more groups of blocks (e.g. tiles (H.265/HEVC and VVC) or bricks (VVC)).

Embodiments of the video decoder 30 as shown in FIG. 3 may be configured to partition and/or decode the picture by using slices/tile groups (also referred to as video tile groups) and/or tiles (also referred to as video tiles), wherein a picture may be partitioned into or decoded using one or more slices/tile groups (typically non-overlapping), and each slice/tile group may comprise, e.g. one or more blocks (e.g. CTUs) or one or more tiles, wherein each tile, e.g. may be of rectangular shape and may comprise one or more blocks (e.g. CTUs), e.g. complete or fractional blocks.

Other variations of the video decoder 30 might be used to decode the encoded picture data 21. For example, the decoder 30 can produce the output video stream without the loop filtering unit 320. For example, a non-transform based decoder 30 can inverse-quantize the residual signal directly without the inverse-transform processing unit 312 for certain blocks or frames. In another implementation, the video decoder 30 can have the inverse-quantization unit 310 and the inverse-transform processing unit 312 combined into a single unit.

It should be understood that, in the encoder 20 and the decoder 30, a processing result of a current step may be further processed and then output to the next step. For example, after interpolation filtering, motion vector derivation or loop filtering, a further operation, such as Clip or shift, may be performed on the processing result of the interpolation filtering, motion vector derivation or loop filtering.

It should be noted that further operations may be applied to the derived motion vectors of current block (including but not limit to control point motion vectors of affine mode, sub-block motion vectors in affine, planar, ATMVP modes, temporal motion vectors, and so on). For example, the value of motion vector is constrained to a predefined range according to its representing bit. If the representing bit of motion vector is bitDepth, then the range is −2{circumflex over ( )}(bitDepth−1)˜2{circumflex over ( )}(bitDepth−1)−1, where “{circumflex over ( )}” means exponentiation. For example, if bitDepth is set equal to 16, the range is −3276832767; if bitDepth is set equal to 18, the range is −131072131071. For example, the value of the derived motion vector (e.g. the MVs of four 4×4 sub-blocks within one 8×8 block) is constrained such that the max difference between integer parts of the four 4×4 sub-block MVs is no more than N pixels, such as no more than 1 pixel. Here provides two methods for constraining the motion vector according to the bitDepth.

FIG. 4 is a schematic diagram of a video coding device 400 according to an embodiment of the disclosure. The video coding device 400 is suitable for implementing the disclosed embodiments as described herein. In an embodiment, the video coding device 400 may be a decoder such as video decoder 30 of FIG. 1A or an encoder such as video encoder 20 of FIG. 1A.

The video coding device 400 comprises ingress ports 410 (or input ports 410) and receiver units (Rx) 420 for receiving data; a processor, logic unit, or central processing unit (CPU) 430 to process the data; transmitter units (Tx) 440 and egress ports 450 (or output ports 450) for transmitting the data; and a memory 460 for storing the data. The video coding device 400 may also comprise optical-to-electrical (OE) components and electrical-to-optical (EO) components coupled to the ingress ports 410, the receiver units 420, the transmitter units 440, and the egress ports 450 for egress or ingress of optical or electrical signals.

The processor 430 is implemented by hardware and software. The processor 430 may be implemented as one or more CPU chips, cores (e.g., as a multi-core processor), FPGAs, ASICs, and DSPs. The processor 430 is in communication with the ingress ports 410, receiver units 420, transmitter units 440, egress ports 450, and memory 460. The processor 430 comprises a coding module 470. The coding module 470 implements the disclosed embodiments described above. For instance, the coding module 470 implements, processes, prepares, or provides the various coding operations. The inclusion of the coding module 470 therefore provides a substantial improvement to the functionality of the video coding device 400 and effects a transformation of the video coding device 400 to a different state. Alternatively, the coding module 470 is implemented as instructions stored in the memory 460 and executed by the processor 430.

The memory 460 may comprise one or more disks, tape drives, and solid-state drives and may be used as an over-flow data storage device, to store programs when such programs are selected for execution, and to store instructions and data that are read during program execution. The memory 460 may be, for example, volatile and/or non-volatile and may be a read-only memory (ROM), random access memory (RAM), ternary content-addressable memory (TCAM), and/or static random-access memory (SRAM).

FIG. 5 is a simplified block diagram of an apparatus 500 that may be used as either or both of the source device 12 and the destination device 14 from FIG. 1 according to an exemplary embodiment.

A processor 502 in the apparatus 500 might be a central processing unit. Alternatively, the processor 502 might be any other type of device, or multiple devices, capable of manipulating or processing information now-existing or hereafter developed. Although the disclosed implementations might be practiced with a single processor as shown, e.g., the processor 502, advantages in speed and efficiency might be achieved using more than one processor.

A memory 504 in the apparatus 500 might be a read only memory (ROM) device or a random access memory (RAM) device in an implementation. Any other suitable type of storage device might be used as the memory 504. The memory 504 can include code and data 506 that is accessed by the processor 502 using a bus 512. The memory 504 can further include an operating system 508 and application programs 510, the application programs 510 including at least one program that permits the processor 502 to perform the methods described here. For example, the application programs 510 can include applications 1 through N, which further include a video coding application that performs the methods described here. The apparatus 500 can also include one or more output devices, such as a display 518. The display 518 may be, in one example, a touch sensitive display that combines a display with a touch sensitive element that is operable to sense touch inputs. The display 518 might be coupled to the processor 502 via the bus 512.

Although depicted here as a single bus, the bus 512 of the apparatus 500 might be composed of multiple buses. Further, the secondary storage 514 might be directly coupled to the other components of the apparatus 500 or might be accessed via a network and can comprise a single integrated unit such as a memory card or multiple units such as multiple memory cards. The apparatus 500 can thus be implemented in a wide variety of configurations.

Some techniques which might be implemented with the current solution of this application are introduced as following. It is noted that the description of the techniques refers to the documents JVET-P2001-v14 and NET-P2002-v2, which can be downloaded from the website http://phenix.int-evry.fr/jvet/. The specific implementation might have different variants based on the techniques introduced by JVET-P2001-v14 and NET-P2002-v2, which is not limited by the present application.

Bi-Predictive Optical Flow Refinement

Bi-predictive optical flow refinement is a process of improving the accuracy of the bi-prediction without explicitly signaling information in the bitstream other than information that is commonly signaled for bi-prediction.

In the bi-prediction, two inter-predictions are obtained according to two motion vectors, after which the predictions are combined by applying weighted averaging. The combined prediction can result in a reduced residual energy, since the quantization noise in the two reference patches (Prediction1, Prediction2) is canceled out, thereby improving coding efficiency compared to uni-prediction. Weighted combination in bi-prediction can be performed by an equation:

Bi-prediction=Prediction1*W1+Prediction2*W2+K,

where W1 and W2 are weighting factors that might be signalled or predefined. K is an additive factor which might also be signalled or predefined. As an example, bi-prediction might be obtained using

Bi-prediction=(Prediction1+Prediction2)/2,

where W1 and W2 are set to 0.5 and K is set to 0.

The goal of optical flow refinement is to improve the accuracy of the bi-prediction. Optical flow is the pattern of apparent motion of image objects between two consecutive frames caused by the movement of object or camera. Optical flow refinement process improves the accuracy of the bi-prediction by applying optical flow equation.

Consider a pixel I(x,y,t) in first frame (x and y corresponding to spatial coordinates, t corresponding to time dimension). It moves by distance (v_(x), v_(y)) in next frame taken after dt time. Since those pixels are the same and intensity does not change, the optical flow equation is given by:

I(x,y,t)=I(x+v _(x) ,y+v _(y) ,t+dt)

I(x,y,t) specifies the intensity (sample value) of a pixel at the coordinates of (x,y,t). Assuming small displacements and that higher order terms in a Taylor series expansion can be ignored, the optical flow equations can also be written as:

${\frac{\partial I}{\partial t} + {v_{\chi}\frac{\partial I}{\partial x}} + {v_{y}\frac{\partial I}{\partial y}}} = 0$

Where

$\frac{\partial I}{\partial x}\mspace{14mu}{and}\mspace{14mu}\frac{\partial I}{\partial y}$

are the horizontal and vertical spatial sample gradients at position (x,y) and

$\frac{\partial I}{\partial t}$

is the partial temporal derivative at (x,y).

The optical flow refinement utilizes the principle above in order to improve the quality of bi-prediction.

The implementation of optical flow refinement typically includes the steps of:

1. Calculating sample gradients;

2. Calculating difference between a first prediction and a second prediction;

3. Calculating displacement of pixels or group of pixels that minimizes the error Δ between the two reference patches obtained using the optical flow equation:

$\Delta = {\left( {I^{(0)} - I^{(1)}} \right) + {v_{x}\left( {{\tau_{0}\frac{\partial I^{(0)}}{\partial x}} + {\tau_{1}\frac{\partial I^{(1)}}{\partial x}}} \right)} + {v_{y}\left( {{\tau_{0}\frac{\partial I^{(0)}}{\partial y}} + {\tau_{1}\frac{\partial I^{(1)}}{\partial y}}} \right)}}$

where I⁽⁰⁾ corresponds to sample value in a first prediction, I⁽¹⁾ is the sample value in a second prediction, v_(x) and v_(y) are the displacements calculated in −x and −y direction, and ∂I⁽⁰⁾/∂x and ∂I⁽⁰⁾/∂y are the gradients in x and y directions. τ₁ and τ₀ denote the distances to the reference pictures, where the first prediction and the second prediction are obtained. Some approaches minimize the sum of squared errors, while some approaches minimize the sum of absolute error. A patch of samples around a given position (x,y) are utilized for solving the minimization problem;

4. Employing a specific implementation of the optical flow equation, such as below:

pred_(BIO)=½·(I ⁽⁰⁾ +I ⁽¹⁾+ν_(x)/2·(τ₁ ∂I ⁽¹⁾ /∂x−τ ₀ ∂I ⁽⁰⁾ /∂x)+v _(y)/2·(τ₁ ∂I ⁽¹⁾ /∂y−τ ₀ ∂I ⁽⁰⁾ /∂y))

Where pred_(BIO) specifies the modified prediction which is the output of the optical flow refinement process.

Sample gradients can be obtained by the following formula

∂I(x,y,t)/∂x=I(x+1,y,t)−I(x−1,y,t)

∂I(x,y,t)/∂y=I(x,y+1,t)−I(x,y−1,t)

In some embodiments, in order to reduce the complexity of estimating the displacement for each pixel, the displacement is estimated for a group of pixels. In some examples, to compute the improved bi-prediction for a block of 4×4 luma samples, the displacements are estimated using sample values of a block of 8×8 luma samples with the 4×4 block of samples at its center.

The input of optical flow refinement process are the prediction samples from two reference pictures and the output of the optical flow refinement is combined prediction (pred_(BIO)) which is calculated according to the optical flow equation.

In some embodiments, the optical flow (v_(x), v_(y)) is determined using the following equations in order to eliminate multiplications involving higher bit-depth terms. The samples used for estimation (i.e. i and j span) are the set of predicted samples from each reference in the neighborhood of the current sample or current block of samples for which the optical flow is estimated. In an example, for a current block of 4×4 samples, a 6×6 block of predicted samples in each reference with the 4×4 block of samples at its center are used.

$\begin{matrix} {{s_{1} = {\sum\limits_{i,j}{{abs}\;\left( {\frac{\partial I^{(0)}}{\partial x} + \frac{\partial I^{(1)}}{\partial x}} \right)}}}{s_{2} = {\sum\limits_{i,j}{{abs}\;\left( {\frac{\partial I^{(0)}}{\partial y} + \frac{\partial I^{(1)}}{\partial y}} \right)}}}{s_{3} = {\sum\limits_{i,j}{{{sign}\left( {\frac{\partial I^{(0)}}{\partial x} + \frac{\partial I^{(1)}}{\partial x}} \right)}*\left( {I^{(1)} - I^{(0)}} \right)}}}{s_{4} = {\sum\limits_{i,j}{{{sign}\left( {\frac{\partial I^{(0)}}{\partial y} + \frac{\partial I^{(1)}}{\partial y}} \right)}*\left( {I^{(1)} - I^{(0)}} \right)}}}{v_{x} = {- \frac{s_{3}}{s_{1}}}}{v_{y} = {- \frac{s_{4}}{s_{2}}}}} & \; \end{matrix}$

In a specific example, the bidirectional optical flow prediction process is introduced.

Inputs to this process are:

-   -   two variables nCbW and nCbH specifying the width and the height         of the current coding block,     -   two (nCbW+2)×(nCbH+2) luma prediction sample arrays         predSamplesL0 and predSamplesL1,     -   the prediction list utilization flags predFlagL0 and predFlagL1,     -   the reference indices refIdxL0 and refIdxL1,     -   the bidirectional optical flow utilization flags         bdofUtilizationFlag[xIdx][yIdx] with xIdx=0 . . . (nCbW>>2)−1,         yIdx=0 . . . (nCbH>>2)−1.

Output of this process is the (nCbW)×(nCbH) array pbSamples of luma prediction sample values.

Variables bitDepth, shift1, shift2, shift3, shift4, offset4, and mvRefineThres are derived as follows:

-   -   The variable bitDepth is set equal to BitDepth_(Y).     -   The variable shift1 is set to equal to Max(2, 14−bitDepth).     -   The variable shift2 is set to equal to Max(8, bitDepth−4).     -   The variable shift3 is set to equal to Max(5, bitDepth−7).     -   The variable shift4 is set equal to Max(3, 15−bitDepth) and the         variable offset4 is set equal to 1<<(shift4−1).     -   The variable mvRefineThres is set equal to Max(2,         1<<(13−bitDepth)).

For xIdx=0 . . . (nCbW>>2)−1 and yIdx=0 . . . (nCbH>>2)−1, the following applies:

-   -   The variable xSb is set equal to (xIdx<<2)+1 and ySb is set         equal to (yIdx<<2)+1.     -   If bdofUtilizationFlag[xSbIdx][yIdx] is equal to FALSE, for         x=xSb−1 . . . xSb+2, y=ySb−1 . . . ySb+2, the prediction sample         values of the current subblock are derived as follows:

pbSamples[x][y]=Clip3(0,(2^(bitDepth))−1,(predSamplesL0[x+1][y+1]+offset2+predSamplesL1[x+1][y+1])>>shift2)

-   -   Otherwise (bdoffitilizationFlag[xSbIdx][yIdx] is equal to TRUE),         the prediction sample values of the current subblock are derived         as follows:         -   For x=xSb−1 . . . xSb+4, y=ySb−1 . . . ySb+4, the following             ordered steps apply:         -   1. The locations (h_(v), v_(y)) for each of the             corresponding sample locations (x, y) inside the prediction             sample arrays are derived as follows:

h _(x)=Clip3(1,nCbW,x)

v _(y)=Clip3(1,nCbH,y)

-   -   -   2. The variables gradientHL0[x][y], gradientVL0[x][y],             gradientHL1[x][y] and gradientVL1[x][y] are derived as             follows:

gradientHL0[x][y]=(predSamplesL0[h _(x)+1][v _(y)]−predSampleL0[h _(x)−1][v _(y)])>>shift1

gradientVL0[x][y]=(predSampleL0[h _(x)][v _(y)+1]−predSampleL0[h _(x)][v _(y)−1])>>shift1

gradientHL1[x][y]=(predSamplesL1[h _(x)+1][v _(y)]predSampleL1[h _(x)−1][v _(y)])>>shift1

gradientVL1[x][y]=(predSampleL1[h _(x)][v _(y)+1]−predSampleL1[h _(x)][v _(y)−1])>>shift1

-   -   3. The variables temp[x][y], tempH[x][y] and tempV[x][y] are         derived as follows:

diff[x][y]=(predSamplesL0[h _(x)][v _(y)]>>shift2)−(predSamplesL1[h _(x)][v _(y)]>>shift2)

tempH[x][y]=(gradientHL0[x][y]+gradientHL11[x][y])>>shift3

tempV[x][y]=(gradientVL0[x][y]+gradientVL1[x][y])>>shift3

-   -   The variables sGx2, sGy2, sGxGy, sGxdI and sGydI are derived as         follows:

sGx2=Σ_(i)Σ_(j)(tempH[xSb+i][ySb+j]*tempH[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGy2=Σ_(i)Σ_(j)(tempV[xSb+i][ySb+j]*tempV[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGxGy=Σ _(i)Σ_(j)(tempH[xSb+i][ySb+j]*tempV[xSb+i][ySb+j]) with i,j−1 . . . 4

sGxdI=Σ _(i)Σ_(j)(−tempH[xSb+i][ySb+j]*diff[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGydI=Σ _(i)Σ_(j)(−tempV[xSb+i][ySb+j]*diff[xSb+i][ySb+j]) with i,j=−1 . . . 4

-   -   The horizontal and vertical motion offset of the current         subblock are derived as:

v _(x) =sGx2>0?Clip3(−mvRefineThres,mvRefineThres,−(sGxdI<<3)>>Floor(Log 2(sGx2))):0

v _(y) =sGy2>0?Clip3(−mvRefineThres,mvRefineThres,((sGydI<<3)−((v _(x) *sGxGy _(m))<<12+v _(x) *sGxGy _(s))>>1)>>Floor(Log 2(sGx2))):0

-   -   For x=xSb−1 . . . xSb+2, y=ySb−1 . . . ySb+2, the prediction         sample values of the current sub-block are derived as follows:

bdofOffset=Round((v _(x)*(gradientHL1[x+1][y+1]−gradientHL0[x+1][y+1]))>>1)+Round((v _(y)*(gradientVL1[x+1][y+1]−gradientVL0[x+1][y+1]))>>1)

pbSamples[x][y]=Clip3(0,(2^(bitDepth))−1,(predSamplesL0[x+1][y+1]+offset4+predSamplesL1[x+1][y+1]+bdofOffset)>>shift4)

Traditional methods for estimating optical flow attempt to minimize the sum of squared values of the error Δ between the two predicted patches using the optical flow equation. These methods require computing squared values for the sum of sample gradients and multiplying the sample difference with the sum of sample gradients. These multiplications increase the bit-depth of the product term and increase the computational complexity and accumulator for the bi-predictive optical flow based refinement. An alternative method for optical flow estimation method eliminates the need for any multiplications by:

-   -   (a) using a sum of absolute values of the sum of gradients in         the two references instead of the sum of square values;     -   (b) replacing the multiplication of sample differences by the         sum of sample gradients with multiplication of sample         differences by the sign of the sum of sample gradients; the         latter can be performed without a multiplication by adding or         subtracting the sample difference value to the accumulated value         based on the sign of the sum of sample gradients.

However, this method suffers a drop in compression efficiency when compared to the method that minimized the sum of squared errors. Hence, there is a need for a method that can reduce this drop in compression efficiency while retaining the computational simplifications offered by such a method.

The embodiments of the present application modify the method of computing the sign of the sum of horizontal sample gradients and sum of vertical sample gradients. Conventional sign(x) evaluation returns a value of 1 for positive values of x, a value of −1 for negative values of x, and a value of 0 when x is 0. In the present application, a pre-determined threshold value T that depends on the bit-depth of the sum of sample gradients is employed.

The sign(x) is modified to return a value of 1 for values of x greater than T, a value of −1 for values of x less than −T, and a value of 0 otherwise. The optical flow estimation method continues to be multiplication-free with such a change.

Alternative embodiments of the current application may quantize the sum of horizontal gradients and sum of vertical gradients to a reduced bit-depth value first (e.g. by shifting the value to the right by a pre-determined number of bit positions). Subsequently, the pre-determined threshold value may also be quantized accordingly before obtaining the sign(x) output value.

In certain embodiments, the current application may replace sign(x) with an output that has more than 3 levels. In one example, the number of output levels is 5. A pre-determined second threshold value T′ is used such that the output value for sum of gradients greater than T′ will be 2 and less than −T′ shall be −2. The multiplication can still be avoided by using arithmetic left shift by 1-bit for the sample differences.

The embodiments of the application improve the coding efficiency by suppressing the sample differences associated with the samples that have a sample gradients value that falls between −T and T. The low computational complexity aspect of the multiplication-free method are retained.

According to a first exemplary embodiment of the application, the steps for bi-prediction of a current coding block comprises the following steps:

Step 0: Obtaining a pair of motion vectors for the current coding block;

In some feasible implementations, two motion vectors are obtained as input. The initial motion vectors can be determined based on an indication information in the bitstream. For example, an index might be signaled in the bitstream, the index indicates a position in a list of candidate motion vectors. In another example, a motion vector predictor index and motion vector difference value can be signaled in the bitstream. In another example, these motion vectors can be derived as a refinement motion vector using motion vector refinement starting from an initial pair of motion vectors that are indicated in the bitstream.

In another example, reference picture indications can be obtained from the bitstream to indicate the reference picture with which a given motion vector in the obtained motion vector pair is associated.

Step 1: Obtaining a block of first predicted samples at an intermediate bit-depth from two reference pictures using the pair of motion vectors;

In some feasible implementations, a first uni-directional prediction is obtained in each reference frame according to the obtained motion vector pair and a K-tap interpolation filter. More specifically, the prediction obtains reconstructed reference sample values when the motion vector corresponds to an integer sample position. If the motion vector has a non-zero horizontal component and a zero vertical component, it performs a horizontal K-tap interpolation to obtain the predicted sample values. If the motion vector has a non-zero vertical component and a zero horizontal component, it performs a vertical K-tap interpolation to obtain the predicted sample values. If the motion vector has non-zero values for both the horizontal and vertical components, a 2-D separable K-tap interpolation is performed with the horizontal interpolation performed first followed by the vertical interpolation to obtain the predicted sample values.

Step 2: Computing an optical flow using the sample differences between the corresponding first predicted samples in each reference, horizontal sample gradients in each reference, and vertical sample gradients in each reference using an optical flow equation; The optical flow computation uses a function that takes either the sum of the horizontal sample gradients across the two references or the sum of the vertical sample gradients across the two references as the input and returns one of N possible values as the output, where N is an odd positive value that is greater than or equal to 3. The return value of the function is based on the sign of the input value and a comparison of the absolute value of the input against a first pre-determined threshold T.

In some feasible implementations, the optical flow is estimated for each sub-block in a given current coding unit using the first set of prediction samples obtained in Step 1 for each reference.

In one example, assuming the prediction samples for the first reference referred to is represented as I⁽⁰⁾ and the prediction samples for the second reference referred to is represented as I⁽¹⁾, horizontal and vertical sample gradients in each reference (referred hereinafter are represented as Gx0, Gy0 in the first reference and Gx1, Gy1 in the second reference), which are computed for a set of positions within the current coding sub-block. The horizontal sample gradient at a position (x,y) is computed by taking the difference between the sample value to the right of this position and the sample value to the left of this position. The vertical sample gradient at a position (x,y) is computed by taking the difference between the sample value below this position and the sample value above this position. The optical flow is then estimated as follows:

$\begin{matrix} {{s_{1} = {\sum\limits_{i,j}{{abs}\;\left( {{{Gx}\; 1} + {{Gx}\; 0}} \right)}}}{s_{2} = {\sum\limits_{i,j}{{abs}\;\left( {{{Gy}\; 1} + {{Gy}0}} \right)}}}{s_{3} = {\sum\limits_{i,j}{{f\left( {{Gx1} + {Gx0}} \right)}*\left( {I^{(1)} - I^{(0)}} \right)}}}{s_{4} = {\sum\limits_{i,j}{{{sign}\left( {{{Gy}\; 1} + {{Gy}0}} \right)}*\left( {I^{(1)} - I^{(0)}} \right)}}}{v_{x} = {- \frac{s_{3}}{s_{1}}}}{v_{y} = {- \frac{s_{4}}{s_{2}}}}} & \; \end{matrix}$

The function f(x) takes the sum of horizontal gradient or sum of vertical gradient as an input and produces an output that takes one of N possible values, where N is a positive, odd integer value greater than or equal to 3. The output value depends on the input value and a first pre-determined threshold T. In one example, N takes the value 3. The output value is one of 3 possible values −1, 0, and 1. This is determined as follows:

f(x)=1, if x>T

f(x)=−1, if x<−T

f(x)=0, if −T≤x≤T

Alternatively, it can be written as:

f(x)=sign(x), if abs(x)>T;

-   -   Otherwise, f(x)=0.

FIG. 6 shows the relationship between the input value (which is the sum of the corresponding sample gradients between the two references in the horizontal or vertical direction) and the output value that takes one of 3 possible values based on the first pre-determined threshold T. The output can be viewed as a type of quantization or partitioning of the dynamic range of the input into 3 parts based on the first pre-determined threshold T such that the function takes one of the possible output values for each partition.

The first pre-determined threshold T is determined using the bit-depth of the sum of sample gradients. In some examples, the sum of sample gradients take a value that depends on the sample bit-depth of the prediction samples. In another example, the sum of sample gradients are adjusted (e.g. right or left shifted through a set of bits) based on the sample bit-depth and a desired bit-depth to be at the desired bit-depth. In one example, when the input bit-depth is 10-bits, T takes a value of 3.

Though the equations for s3 and s4 show a multiplication for each term of the sum, it is understood that the summation can be implemented without multiplication by conditionally adding or subtracting the sample difference for a given (i,j) combination to the accumulator when the non-zero output value. Specifically, the sample difference is added when the output value is 1 and the sample difference is subtracted when the output value is −1.

In another example, f(x) may produce an output that can take one out of N=5 possible values, namely, −2, −1, 0, 1, 2, as shown in FIG. 7. The second pre-determined threshold T′ in the figure depends on the dynamic range of the input and the desired number of output levels.

In an example, the dynamic range of the input is partitioned into 4 equal parts. In other words, if the input is a 10-bit signed value, the dynamic range can be between −512 and 511. This is partitioned into ranges (−512 to −257), (−256 to −1), (0, 255), and (256, 512). Hence, a second pre-determined threshold T′ is 256 in this example. The output value for inputs in the range (−512 to −257) is −2. The range (−256 to −1) is split into (−256 to −T−1) and (−T to −1). The output value for inputs in the range (−256 to −T−1) is −1. The range (0,255) is split into range (0 to T) and (T+1 to 255). The output value for inputs in the range (−T to T) is 0. The output value for inputs in the range (T+1 to 255) is 1. The output value for inputs in the range (256 to 511) is 2. Thus, the output value can take the 5 possible values −2, −1, 0, 1, and 2.

Step 3: Obtaining the final inter bi-predicted samples for the current coding block using the first predicted samples in each reference, computed optical flow, and the horizontal and vertical sample gradient values in each reference.

FIG. 8 illustrates a processing of the current application. The block 810 corresponds to step 0, wherein an MV pair is obtained with respect to a pair of reference pictures for a current coding block. The block 820 corresponds to step 1, wherein a first prediction is obtained in each reference using the obtained MV pair and the reconstructed reference luma samples of the pair of references. The block 830 corresponds to step 2, wherein an optical flow is computed based on the first predictions obtained in each reference. The optical flow computation depends on the sample differences and the sum of sample gradients in the horizontal and vertical directions. The optical flow computation uses a function that takes the sum of sample gradients in the horizontal or vertical direction and produces an output value that depends on the sign of the input value and a first pre-determined threshold to produce an output value. The output value can take one of N possible values, where N is a small, positive, odd integer that takes values greater than or equal to 3. Block 840 corresponds to step 3, wherein the bi-prediction samples for the current coding block are obtained based on the first prediction samples and the computed optical flow.

FIG. 9 illustrates another processing of the current application.

S901: obtaining an initial motion vector pair of the bi-prediction for a current block.

The initial motion vector pair might be obtained by any traditional bi-prediction method, for example, merge mode, advanced motion vector perdition (AMVP) mode, Affine mode and so on. Generally, the initial motion vector pair is obtained according to motion information of at least one spatial and/or temporal neighboring block of the current block. The current block might be a coding unit or a sub-block of the coding unit.

S902: obtaining a forward prediction block and a backward prediction block using the initial motion vector pair.

It is understandable that for every sample in the current block, a forward prediction sample and a backward prediction sample corresponding to said sample are determined in the forward prediction block and backward prediction block respectively.

S903: calculating gradient parameters for a sample in the current block based on the corresponding forward prediction sample and backward prediction sample.

For example, gradient parameters might comprise a forward horizontal gradient, a backward horizontal gradient, a backward horizontal gradient and a backward horizontal gradient.

Assuming the sample is pbSamples[x][y], the forward prediction sample is predSamplesL0[x][y] and the backward prediction sample is predSamplesL1[x] [y].

The forward horizontal gradient:

gradientHL0[x][y]=predSamplesL0[x+1][y]−predSamplesL0[x−1][y];

The forward vertical gradient:

gradientVL0[x][y]=predSamplesL0[x][y+1]−predSamplesL0[x][y−1];

The backward horizontal gradient:

gradientHL1[x][y]=predSamplesL1[x+1][y]−predSamplesL1[x−1][y];

The backward vertical gradient:

gradientVL1[x][y]=predSamplesL1[x][y+1]−predSamplesL1[x][y−1];

S904: obtaining sample optical flow parameters for the sample based on the gradient parameters.

For example, the sample optical flow parameters might comprise a sample difference, a horizontal average gradient and a vertical average gradient.

The sample difference:

diff[x][y]=predSamplesL0[x][y]−predSamplesL1[x][y];

The horizontal average gradient:

TempH[x][y]=(gradientHL0[x][y]+gradientHL1[x][y])/2;

The vertical average gradient:

TempV[x][y]=(gradientVL0[x][y]+gradientVL1[x][y])/2.

S905: obtaining block optical flow parameters based on at least parts of the sample optical flow parameters for the samples in the current block.

At least one of block optical flow parameters is obtained by a multiplication between a first sample optical flow parameter and an output value of a sign function of a second sample optical flow parameter.

In an example, the sign function is:

$\begin{matrix} {{{Sign}(x)} = \left\{ \begin{matrix} {1;} & {x > T} \\ {0;} & {{- T} \leqslant x \leqslant T} \\ {{{- 1};}\ } & {x < {- T}} \end{matrix} \right.} & \; \end{matrix}$

In another example, T is 0, accordingly, the sign function is:

${{Sign}(x)} = \left\{ \begin{matrix} {1;} & {x > 0} \\ {0;} & {x==0} \\ {{- 1};} & {x < 0} \end{matrix} \right.$

In an example, the sign function is:

${{Sign}\mspace{11mu}(x)} = \left\{ \begin{matrix} {2;} & {x > {2T}} \\ {1;} & {T < x \leqslant {2T}} \\ {0;} & {{- T} \leqslant x \leqslant T} \\ {{- 1};} & {{{- 2}T} \leqslant x < {- T}} \\ {{- 2};} & {x < {{- 2}T}} \end{matrix} \right.$

And in this example, it is understandable that multiplying 2 can be replaced by a 1 bit left shift operation, so the multiplication can also be avoided.

For example, assuming the current block is a 4×4 block, the coordinate of the top-let sample of the current block is (xSb, ySb), the block optical flow parameters might comprises:

sGx2=Σ_(i)Σ_(j) Abs(tempH[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGy2=Σ_(i)Σ_(j) Abs(tempV[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGxGy=Σ _(i)Σ_(j)(Sign(tempV[xSb+i][ySb+j])*tempH[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGxGy _(m) =sGxGy>>12

sGxGy _(s) =sGxGy&((1<<12)−1)

sGxdI=Σ _(i)Σ_(j)(−Sign(tempH[xSb+i][ySb+j])*diff[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGydI=Σ _(i)Σ_(j)(−Sign(tempV[xSb+i][ySb+j])*diff[xSb+i][ySb+j]) with i,j=−1 . . . 4

S906: obtaining the prediction value of the current block based on the forward prediction block, the backward prediction block, the block optical flow parameters and the sample optical flow parameters.

According to the embodiment illustrated in FIG. 9, another specific example is introduced.

Inputs to this process are:

-   -   two variables nCbW and nCbH specifying the width and the height         of the current coding block,     -   two (nCbW+2)x(nCbH+2) luma prediction sample arrays         predSamplesL0 and predSamplesL1,     -   the prediction list utilization flags predFlagL0 and predFlagL1,     -   the reference indices refIdxL0 and refIdxL1,     -   the bi-directional optical flow utilization flag sbBdofFlag.

Output of this process is the (nCbW)x(nCbH) array pbSamples of luma prediction sample values. The variables shift1, shift2, shift3, shift4, offset4, and mvRefineThres are derived as follows:

-   -   The variable shift1 is set to equal to 6.     -   The variable shift2 is set to equal to 4.     -   The variable shift3 is set to equal to 1.     -   The variable shift4 is set equal to Max(3, 15−BitDepth) and the         variable offset4 is set equal to 1<<(shift4−1).     -   The variable mvRefineThres is set equal to 1<<5.

For xIdx=0 . . . (nCbW>>2)−1 and yIdx=0 . . . (nCbH>>2)−1, the following applies:

-   -   The variable xSb is set equal to (xIdx<<2)+1 and ySb is set         equal to (yIdx<<2)+1.     -   If sbBdofFlag is equal to FALSE, for x=xSb−1 . . . xSb+2,         y=ySb−1 . . . ySb+2, the prediction sample values of the current         subblock are derived as follows:

pbSamples[x][y]=Clip3(0,(2^(BitDepth))−1,(predSamplesL0[x+1][y+1]+offset4+predSamplesL1[x+1][y+1])>>shift4)

-   -   Otherwise (sbBdofFlag is equal to TRUE), the prediction sample         values of the current subblock are derived as follows:         -   For x=xSb−1 . . . xSb+4, y=ySb−1 . . . ySb+4, the following             ordered steps apply:         -   4. The locations (h_(x), v_(y)) for each of the             corresponding sample locations (x, y) inside the prediction             sample arrays are derived as follows:

h _(x)=Clip3(1,nCbW,x)

v _(y)=Clip3(1,nCbH,y)

-   -   -   5. The variables gradientHL0[x][y], gradientVL0[x][y],             gradientHL1[x][y] and gradientVL1[x][y] are derived as             follows:

gradientHL0[x][y]=(predSamplesL0[h _(x)+1][v _(y)]>>shift1)−(predSamplesL0[h _(x)−1][v _(y)])>>shift1)

gradientVL0[x][y]=(predSamplesL0[h _(x)][v _(y)+1]>>shift1)−(predSamplesL0[h _(x)][v _(y)−1])>>shift1)

gradientHL1[x][y]=(predSamplesL1[h _(x)+1][v _(y)]>>shift1)−(predSamplesL1[h _(x)−1][v _(y)])>>shift1)

gradientVL1[x][y]=(predSamplesL1[h _(x)][v _(y)+1]>>shift1)−(predSamplesL1[h _(x)][v _(y)−1])>>shift1)

-   -   -   6. The variables diff[x][y], tempH[x][y] and tempV[x][y] are             derived as follows:

diff[x][y]=(predSamplesL0[h _(x)][v _(y)]>>shift2)−(predSamplesL1[h _(x)][v _(y)]>>shift2)

tempH[x][y]=(gradientHL0[x][y]+gradientH1[x][y])>>shift3

tempV[x][y]=(gradientVL0[x][y]+gradientVL1[x][y])>>shift3

-   -   -   The variables sGx2, sGy2, sGxGy, sGxdI and sGydI are derived             as follows:

sGx2=Σ_(i)Σ_(j) Abs(tempH[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGy2=Σ_(i)Σ_(j) Abs(tempV[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGxGy=Σ _(i)Σ_(j)(Sign(tempV[xSb+i][ySb+j])*tempH[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGxGy _(m) =sGxGy>>12

sGxGy _(s) =sGxGy&((1<<12)−1)

sGxdI=Σ _(i)Σ_(j)(−Sign(tempH[xSb+i][ySb+j])*diff[xSb+i][ySb+j]) with i,j=−1 . . . 4

sGydI=Σ _(i)Σ_(j)((−Sign(tempV[xSb+i][ySb+j])*diff[xSb+i][ySb+j]) with i,j=−1 . . . 4

-   -   -   The horizontal and vertical motion offset of the current             subblock are derived as:

v _(x) =sGx2>0?Clip3(−mvRefineThres+1,mvRefineThres−1,−−(sGxdI≤≤2)>>Floor(Log 2(sGx2))):0

v _(y) =sGy2>0?Clip3(−mvRefineThres+1,mvRefineThres−1,((sGydI<<2)−((v _(x) *sGxGy _(m))<<12+v _(x) *sGxGy _(s))>>1)>>Floor(Log 2(sGy2))):0

-   -   -   For x=xSb−1 . . . xSb+2, y=ySb−1 . . . ySb+2, the prediction             sample values of the current sub-block are derived as             follows:

bdofOffset=v _(x)*(gradientHL0[x+1][y+1]−gradientHL1[x+1][y+1])+v _(y)*(gradientVL0[x+1][y+1]−gradientVL1[x+1][y+1])

pbSamples[x][y]=Clip3(0,(2^(BitDepth))−1,(predSamplesL0[x+1][y+1]+offset4+predSamplesL1[x+1][y+1]+bdofOffset)>>shift4)

In another embodiment, FIG. 10 illustrates an apparatus of the current application.

A bidirectional optical flowing prediction apparatus 1000, comprising: an obtaining module 1001, configured to obtain an initial motion vector pair for a current block, wherein the initial motion vector pair comprises a forward motion vector and a backward motion vector; a patching module 1002, configured to obtain a forward prediction block according to the forward motion vector and a backward prediction block according to the backward motion vector; a gradient module 1003, configured to calculate gradient parameters for a current sample in the current block based on a forward prediction sample and a backward prediction sample corresponding to the current sample, wherein the forward prediction sample is in the forward prediction block and the backward prediction sample is in the backward prediction block; a calculating module 1004, configured to obtain at least two sample optical flow parameters for the current sample based on the gradient parameters, wherein the sample optical flow parameters comprises a first parameter and a second parameter; a training module 1005, configured to obtain block optical flow parameters based on sample optical flow parameters of samples in the current block, wherein one of the block optical flow parameters is obtained by an operation including multiplying a value of the first parameter and a value of a sign function of the second parameter, and wherein the sign function is a piecewise function with at least three subintervals; and a predicting module 1006, configured to obtain a prediction value of the current block based on the forward prediction block, the backward prediction block, the block optical flow parameters and the sample optical flow parameters.

In a feasible implementation, the sign function is

${{Sign}\mspace{11mu}(x)} = \left\{ \begin{matrix} {1;} & {x > T} \\ {0;} & {{- T} \leqslant x \leqslant T} \\ {{- 1};} & {x < {- T}} \end{matrix} \right.$

wherein T is a non-negative real number.

In a feasible implementation, T is 0; correspondingly, the sign function is

${{Sign}\mspace{11mu}(x)} = \left\{ \begin{matrix} {1;} & {x > 0} \\ {0;} & {x==0} \\ {{- 1};} & {x < 0} \end{matrix} \right.$

In a feasible implementation, the initial motion vector pair is obtained according to motion information of at least one spatial and/or temporal neighboring block of the current block.

In a feasible implementation, the current block is a coding unit or a sub-block of the coding unit.

In a feasible implementation, gradient parameters comprise a forward horizontal gradient, a backward horizontal gradient, a forward vertical gradient and a backward vertical gradient.

In a feasible implementation, the forward horizontal gradient is a difference of a right sample and a left sample adjacent to the forward prediction sample.

In a feasible implementation, the backward horizontal gradient is a difference of a right sample and a left sample adjacent to the backward prediction sample.

In a feasible implementation, the forward vertical gradient is a difference of a bottom sample and an upper sample adjacent to the forward prediction sample.

In a feasible implementation, the backward vertical gradient is a difference of a bottom sample and an upper sample adjacent to the backward prediction sample.

In a feasible implementation, the sample optical flow parameters comprise a sample difference, a horizontal average gradient and a vertical average gradient.

In a feasible implementation, the first parameter is the sample difference, the horizontal average gradient or the vertical average gradient;

In a feasible implementation, the second parameter is the sample difference, the horizontal average gradient or the vertical average gradient, and the second parameter is not the first parameter.

In another embodiment, FIG. 11 illustrates another apparatus of the current application.

A bidirectional optical flowing prediction apparatus 1100, comprising: one or more processors 1101; and a non-transitory computer-readable storage medium 1102 coupled to the processors and storing programming for execution by the processors, wherein the programming, when executed by the processors, configures the apparatus to carry out any one of methods illustrated in FIG. 9.

In another embodiment of the current application, a computer program product comprising a program code for performing any one of methods illustrated in FIG. 9.

Following is an explanation of the applications of the encoding method as well as the decoding method as shown in the above-mentioned embodiments, and a system using them.

FIG. 12 is a block diagram showing a content supply system 3100 for realizing content distribution service. This content supply system 3100 includes capture device 3102, terminal device 3106, and optionally includes display 3126. The capture device 3102 communicates with the terminal device 3106 over communication link 3104. The communication link may include the communication channel 13 described above. The communication link 3104 includes but not limited to WIFI, Ethernet, Cable, wireless (3G/4G/5G), USB, or any kind of combination thereof, or the like.

The capture device 3102 generates data, and may encode the data by the encoding method as shown in the above embodiments. Alternatively, the capture device 3102 may distribute the data to a streaming server (not shown in the Figures), and the server encodes the data and transmits the encoded data to the terminal device 3106. The capture device 3102 includes but not limited to camera, smart phone or Pad, computer or laptop, video conference system, PDA, vehicle mounted device, or a combination of any of them, or the like. For example, the capture device 3102 may include the source device 12 as described above. When the data includes video, the video encoder 20 included in the capture device 3102 may actually perform video encoding processing. When the data includes audio (i.e., voice), an audio encoder included in the capture device 3102 may actually perform audio encoding processing. For some practical scenarios, the capture device 3102 distributes the encoded video and audio data by multiplexing them together. For other practical scenarios, for example in the video conference system, the encoded audio data and the encoded video data are not multiplexed. Capture device 3102 distributes the encoded audio data and the encoded video data to the terminal device 3106 separately.

In the content supply system 3100, the terminal device 310 receives and reproduces the encoded data. The terminal device 3106 could be a device with data receiving and recovering capability, such as smart phone or Pad 3108, computer or laptop 3110, network video recorder (NVR)/digital video recorder (DVR) 3112, TV 3114, set top box (STB) 3116, video conference system 3118, video surveillance system 3120, personal digital assistant (PDA) 3122, vehicle mounted device 3124, or a combination of any of them, or the like capable of decoding the above-mentioned encoded data. For example, the terminal device 3106 may include the destination device 14 as described above. When the encoded data includes video, the video decoder 30 included in the terminal device is prioritized to perform video decoding. When the encoded data includes audio, an audio decoder included in the terminal device is prioritized to perform audio decoding processing.

For a terminal device with its display, for example, smart phone or Pad 3108, computer or laptop 3110, network video recorder (NVR)/digital video recorder (DVR) 3112, TV 3114, personal digital assistant (PDA) 3122, or vehicle mounted device 3124, the terminal device can feed the decoded data to its display. For a terminal device equipped with no display, for example, STB 3116, video conference system 3118, or video surveillance system 3120, an external display 3126 is contacted therein to receive and show the decoded data.

When each device in this system performs encoding or decoding, the picture encoding device or the picture decoding device, as shown in the above-mentioned embodiments, might be used. FIG. 13 is a diagram showing a structure of an example of the terminal device 3106. After the terminal device 3106 receives stream from the capture device 3102, the protocol proceeding unit 3202 analyzes the transmission protocol of the stream. The protocol includes but not limited to Real Time Streaming Protocol (RTSP), Hyper Text Transfer Protocol (HTTP), HTTP Live streaming protocol (HLS), MPEG-DASH, Real-time Transport protocol (RTP), Real Time Messaging Protocol (RTMP), or any kind of combination thereof, or the like.

After the protocol proceeding unit 3202 processes the stream, stream file is generated. The file is outputted to a demultiplexing unit 3204. The demultiplexing unit 3204 can separate the multiplexed data into the encoded audio data and the encoded video data. As described above, for some practical scenarios, for example in the video conference system, the encoded audio data and the encoded video data are not multiplexed. In this situation, the encoded data is transmitted to video decoder 3206 and audio decoder 3208 without through the demultiplexing unit 3204.

Via the demultiplexing processing, video elementary stream (ES), audio ES, and optionally subtitle are generated. The video decoder 3206, which includes the video decoder 30 as explained in the above mentioned embodiments, decodes the video ES by the decoding method as shown in the above-mentioned embodiments to generate video frame, and feeds this data to the synchronous unit 3212. The audio decoder 3208, decodes the audio ES to generate audio frame, and feeds this data to the synchronous unit 3212. Alternatively, the video frame may store in a buffer (not shown in FIG. 13) before feeding it to the synchronous unit 3212. Similarly, the audio frame may store in a buffer (not shown in FIG. 13) before feeding it to the synchronous unit 3212.

The synchronous unit 3212 synchronizes the video frame and the audio frame, and supplies the video/audio to a video/audio display 3214. For example, the synchronous unit 3212 synchronizes the presentation of the video and audio information. Information may code in the syntax using time stamps concerning the presentation of coded audio and visual data and time stamps concerning the delivery of the data stream itself.

If subtitle is included in the stream, the subtitle decoder 3210 decodes the subtitle, and synchronizes it with the video frame and the audio frame, and supplies the video/audio/subtitle to a video/audio/subtitle display 3216.

The present application is not limited to the above-mentioned system, and either the picture encoding device or the picture decoding device in the above-mentioned embodiments might be incorporated into other system, for example, a car system.

Mathematical Operators

The mathematical operators used in this application are similar to those used in the C programming language. However, the results of integer division and arithmetic shift operations are defined more precisely, and additional operations are defined, such as exponentiation and real-valued division. Numbering and counting conventions generally begin from 0, e.g., “the first” is equivalent to the 0-th, “the second” is equivalent to the 1-th, etc.

Arithmetic Operators

The following arithmetic operators are defined as follows:

-   -   + Addition     -   − Subtraction (as a two-argument operator) or negation (as a         unary prefix operator)     -   * Multiplication, including matrix multiplication     -   x^(y) Exponentiation. Specifies x to the power of y. In other         contexts, such notation is used for superscripting not intended         for interpretation as exponentiation.     -   / Integer division with truncation of the result toward zero.         For example, 7/4 and −7/−4 are truncated to 1 and −7/4 and 7/−4         are truncated to −1.     -   ÷ Used to denote division in mathematical equations where no         truncation or rounding is intended.

$\frac{x}{y}$

Used to denote division in mathematical equations where no truncation or rounding is intended.

$\sum\limits_{i = x}^{y}{f(i)}$

The summation of f(i) with i taking all integer values from x up to and including y.

-   -   x % y Modulus. Remainder of x divided by y, defined only for         integers x and y with x>=0 and y>0.

Logical Operators

The following logical operators are defined as follows:

-   -   x && y Boolean logical “and” of x and y     -   x∥y Boolean logical “or” of x and y     -   ! Boolean logical “not”     -   x ? y: z If x is TRUE or not equal to 0, evaluates to the value         of y; otherwise, evaluates to the value of z.

Relational Operators

The following relational operators are defined as follows:

-   -   > Greater than     -   >= Greater than or equal to     -   < Less than     -   <= Less than or equal to     -   == Equal to     -   != Not equal to

When a relational operator is applied to a syntax element or variable that has been assigned the value “na” (not applicable), the value “na” is treated as a distinct value for the syntax element or variable. The value “na” is considered not to be equal to any other value.

Bit-Wise Operators

The following bit-wise operators are defined as follows:

-   -   & Bit-wise “and”. When operating on integer arguments, operates         on a two's complement representation of the integer value. When         operating on a binary argument that contains fewer bits than         another argument, the shorter argument is extended by adding         more significant bits equal to 0.     -   | Bit-wise “or”. When operating on integer arguments, operates         on a two's complement representation of the integer value. When         operating on a binary argument that contains fewer bits than         another argument, the shorter argument is extended by adding         more significant bits equal to 0.     -   {circumflex over ( )}Bit-wise “exclusive or”. When operating on         integer arguments, operates on a two's complement representation         of the integer value. When operating on a binary argument that         contains fewer bits than another argument, the shorter argument         is extended by adding more significant bits equal to 0.     -   x>>y Arithmetic right shift of a two's complement integer         representation of x by y binary digits. This function is defined         only for non-negative integer values of y. Bits shifted into the         most significant bits (MSBs) as a result of the right shift have         a value equal to the MSB of x prior to the shift operation.     -   x<<y Arithmetic left shift of a two's complement integer         representation of x by y binary digits. This function is defined         only for non-negative integer values of y. Bits shifted into the         least significant bits (LSBs) as a result of the left shift have         a value equal to 0.

Assignment Operators

The following arithmetic operators are defined as follows:

-   -   = Assignment operator     -   ++ Increment, i.e., x++ is equivalent to x=x+1; when used in an         array index, evaluates to the value of the variable prior to the         increment operation.     -   −− Decrement, i.e., x−− is equivalent to x=x−1; when used in an         array index, evaluates to the value of the variable prior to the         decrement operation.     -   += Increment by amount specified, i.e., x+=3 is equivalent to         x=x+3, and x+=(−3) is equivalent to x=x+(−3).     -   −= Decrement by amount specified, i.e., x−=3 is equivalent to         x=x−3, and x−=(−3) is equivalent to x=x−(−3).

Range Notation

The following notation is used to specify a range of values:

-   -   x=y . . . z x takes on integer values starting from y to z,         inclusive, with x, y, and z being integer numbers and z being         greater than y.

Mathematical Functions

The following mathematical functions are defined:

${{Abs}\;(x)} = \left\{ \begin{matrix} {x;} & {x>=0} \\ {- {x:}} & {x < 0} \end{matrix} \right.$

-   -   A sin(x) the trigonometric inverse sine function, operating on         an argument x that is in the range of −1.0 to 1.0, inclusive,         with an output value in the range of −π÷2 to π÷2, inclusive, in         units of radians     -   A tan(x) the trigonometric inverse tangent function, operating         on an argument x, with an output value in the range of −π÷2 to         π÷2, inclusive, in units of radians

${A\;\tan\; 2\left( {y,\ x} \right)} = \left\{ \begin{matrix} {{A\;{\tan\left( \frac{y}{x} \right)}};} & {x > 0} \\ {{{A\;{\tan\left( \frac{y}{x} \right)}} + \pi};} & {{x < 0}\&\&{y>=0}} \\ {{{A\;{\tan\left( \frac{y}{x} \right)}} - \pi};} & {{x < 0}\&\&{y < 0}} \\ {{+ \frac{\pi}{2}};} & {{x==0}\&\&{y>=0}} \\ {{- \frac{\pi}{2}};} & {otherwise} \end{matrix} \right.$

-   -   Ceil(x) the smallest integer greater than or equal to x.     -   Clip1_(Y)(x)=Clip3(0, (1<<BitDepth_(Y))−1, x)     -   Clip1_(C)(x)=Clip3(0, (1<<BitDepth_(C))−1, x)

${Clip3\left( {x,y,z} \right)} = \left\{ \begin{matrix} {x;} & {z < x} \\ {y;} & {z > y} \\ {z;} & {otherwise} \end{matrix} \right.$

-   -   Cos(x) the trigonometric cosine function operating on an         argument x in units of radians.     -   Floor(x) the largest integer less than or equal to x.

${{GetCurrMsb}\left( {a,b,c,d} \right)} = \left\{ \begin{matrix} {{c + d}\ ;} & {{{b - a} >} = {d\text{/}2}} \\ {{{c - d};}\ } & {{a - b} > {d\text{/}2}} \\ {{c;}\ } & {otherwise} \end{matrix} \right.$

-   -   Ln(x) the natural logarithm of x (the base-e logarithm, where e         is the natural logarithm base constant 2.718 281 828 . . . ).     -   Log 2(x) the base-2 logarithm of x.     -   Log 10(x) the base-10 logarithm of x.

${{Min}\left( {x,y} \right)} = \left\{ {{\begin{matrix} {x;} & {x<=y} \\ {y;} & {x > y} \end{matrix}{Max}\left( {x,y} \right)} = \left\{ \begin{matrix} {x;} & {x>=y} \\ {y;} & {x < y} \end{matrix} \right.} \right.$

-   -   Round(x)=Sign(x)*Floor(Abs(x)+0.5)

${{Sign}\mspace{11mu}(x)} = \left\{ \begin{matrix} {1;} & {x > 0} \\ {0;} & {x==0} \\ {{- 1};} & {x < 0} \end{matrix} \right.$

-   -   Sin(x) the trigonometric sine function operating on an argument         x in units of radians     -   Sqrt(x)=√{square root over (x)}     -   Swap(x, y)=(y, x)     -   Tan(x) the trigonometric tangent function operating on an         argument x in units of radians

Order of Operation Precedence

When an order of precedence in an expression is not indicated explicitly by use of parentheses, the following rules apply:

-   -   Operations of a higher precedence are evaluated before any         operation of a lower precedence.     -   Operations of the same precedence are evaluated sequentially         from left to right.

The table below specifies the precedence of operations from highest to lowest; a higher position in the table indicates a higher precedence.

For those operators that are also used in the C programming language, the order of precedence used in this Specification is the same as used in the C programming language.

TABLE Operation precedence from highest (at top of table) to lowest (at bottom of table)   operations (with operands x, y, and z) ″x++″, ″x−−″ ″!x″, ″−x″ (as a unary prefix operator) x^(y) ″x * y″, ″x / y″, ″x ÷ y″, ″x/y″, ″x % y″ ${{\,^{''}x} + y^{''}},{{\,^{''}x} - {y^{''}\mspace{14mu}\left( {{as}\mspace{14mu} a\mspace{14mu}{two}\text{-}{argument}\mspace{14mu}{operator}} \right)}},{\,^{''}{\sum\limits_{i = x}^{y}{f(i)}^{''}}}$ ″x << y″, ″x >> y″ ″x < y″, ″x <= y″, ″x > y″, ″x >= y″ ″x = = y″, ″x != y″ ″x & y″ ″x | y″ ″x && y″ ″x | | y″ ″x ? y : z″ ″x..y″ ″x = y″, ″x += y″, ″x −= y″

Text Description of Logical Operations

In the text, a statement of logical operations as would be described mathematically in the following form:

if( condition 0 )  statement 0 else if( condition 1 )  statement 1 . . . else /* informative remark on remaining condition */  statement n

may be described in the following manner:

-   -   . . . as follows/ . . . the following applies:         -   If condition 0, statement 0         -   Otherwise, if condition 1, statement 1         -   . . .         -   Otherwise (informative remark on remaining condition),             statement n

Each “If . . . Otherwise, if . . . Otherwise, . . . ” statement in the text is introduced with “ . . . as follows” or “ . . . the following applies” immediately followed by “If . . . ”. The last condition of the “If . . . Otherwise, if . . . Otherwise, . . . ” is always an “Otherwise, . . . ”. Interleaved “If . . . Otherwise, if . . . Otherwise, . . . ” statements might be identified by matching “ . . . as follows” or “ . . . the following applies” with the ending “Otherwise, . . . ”.

In the text, a statement of logical operations as would be described mathematically in the following form:

if( condition 0a && condition 0b )  statement 0 else if( condition 1a | | condition 1b )  statement 1 . . . else  statement n

may be described in the following manner:

-   -   . . . as follows/ . . . the following applies:         -   If all of the following conditions are true, statement ( ):             -   condition 0a             -   condition 0b         -   Otherwise, if one or more of the following conditions are             true, statement 1:             -   condition 1a             -   condition 1b         -   . . .         -   Otherwise, statement n

In the text, a statement of logical operations as would be described mathematically in the following form:

if( condition 0 )  statement 0 if( condition 1 )  statement 1

may be described in the following manner:

-   -   When condition 0, statement 0     -   When condition 1, statement 1.

Embodiments, e.g. of the encoder 20 and the decoder 30, and functions described herein, e.g. with reference to the encoder 20 and the decoder 30, may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on a computer-readable medium or transmitted over communication media as one or more instructions or code and executed by a hardware-based processing unit. Computer-readable media may include computer-readable storage media, which corresponds to a tangible medium such as data storage media, or communication media including any medium that facilitates transfer of a computer program from one place to another, e.g., according to a communication protocol. In this manner, computer-readable media generally may correspond to (1) tangible computer-readable storage media which is non-transitory or (2) a communication medium such as a signal or carrier wave. Data storage media may be any available media that might be accessed by one or more computers or one or more processors to retrieve instructions, code and/or data structures for implementation of the techniques described in this disclosure. A computer program product may include a computer-readable medium.

By way of example, and not limiting, such computer-readable storage media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage, or other magnetic storage devices, flash memory, or any other medium that might be used to store desired program code in the form of instructions or data structures and that might be accessed by a computer. Also, any connection is properly termed a computer-readable medium. For example, if instructions are transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. It should be understood, however, that computer-readable storage media and data storage media do not include connections, carrier waves, signals, or other transitory media, but are instead directed to non-transitory, tangible storage media. Disk and disc, as used herein, includes compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc, where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media. Instructions may be executed by one or more processors, such as one or more digital signal processors (DSPs), general purpose microprocessors, application specific integrated circuits (ASICs), field programmable logic arrays (FPGAs), or other equivalent integrated or discrete logic circuitry. Accordingly, the term “processor,” as used herein may refer to any of the foregoing structure or any other structure suitable for implementation of the techniques described herein. In addition, in some aspects, the functionality described herein may be provided within dedicated hardware and/or software modules configured for encoding and decoding, or incorporated in a combined codec. Also, the techniques could be fully implemented in one or more circuits or logic elements.

The techniques of this disclosure may be implemented in a wide variety of devices or apparatuses, including a wireless handset, an integrated circuit (IC) or a set of ICs (e.g., a chip set). Various components, modules, or units are described in this disclosure to emphasize functional aspects of devices configured to perform the disclosed techniques, but do not necessarily require realization by different hardware units. Rather, as described above, various units may be combined in a codec hardware unit or provided by a collection of interoperative hardware units, including one or more processors as described above, in conjunction with suitable software and/or firmware. 

1. A bidirectional optical flowing prediction method performed by a coding device, comprising: obtaining an initial motion vector pair for a current block, wherein the initial motion vector pair comprises a forward motion vector and a backward motion vector; obtaining a forward prediction block according to the forward motion vector and a backward prediction block according to the backward motion vector; calculating gradient parameters for a current sample in the current block based on a forward prediction sample and a backward prediction sample corresponding to the current sample, wherein the forward prediction sample is in the forward prediction block and the backward prediction sample is in the backward prediction block; obtaining at least two sample optical flow parameters for the current sample based on the gradient parameters, wherein the sample optical flow parameters comprises a first parameter and a second parameter; obtaining block optical flow parameters based on sample optical flow parameters of samples in the current block, wherein one of the block optical flow parameters is obtained by an operation including multiplying a value of the first parameter and a value of a sign function of the second parameter, and wherein the sign function is a piecewise function with at least three subintervals; and obtaining a prediction value of the current block based on the forward prediction block, the backward prediction block, the block optical flow parameters and the sample optical flow parameters.
 2. The method of claim 1, wherein the sign function is ${{Sign}\mspace{11mu}(x)} = \left\{ \begin{matrix} {1;} & {x > T} \\ {0;} & {{- T} \leqslant x \leqslant T} \\ {{- 1};} & {x < {- T}} \end{matrix} \right.$ wherein T is a non-negative real number.
 3. The method of claim 2, wherein T is 0; correspondingly, the sign function is ${{Sign}\mspace{11mu}(x)} = \left\{ \begin{matrix} {1;} & {x > 0} \\ {0;} & {x==0} \\ {{- 1};} & {x < 0} \end{matrix} \right.$
 4. The method of claim 1, wherein the initial motion vector pair is obtained according to motion information of at least one spatial and/or temporal neighboring block of the current block.
 5. The method of claim 1, wherein the current block is a coding unit or a sub-block of the coding unit.
 6. The method of claim 1, wherein gradient parameters comprise a forward horizontal gradient, a backward horizontal gradient, a forward vertical gradient and a backward vertical gradient.
 7. The method of claim 6, wherein the forward horizontal gradient is a difference of a right sample and a left sample adjacent to the forward prediction sample.
 8. The method of claim 6, wherein the backward horizontal gradient is a difference of a right sample and a left sample adjacent to the backward prediction sample.
 9. The method of claim 6, wherein the forward vertical gradient is a difference of a bottom sample and an upper sample adjacent to the forward prediction sample.
 10. The method of claim 6, wherein the backward vertical gradient is a difference of a bottom sample and an upper sample adjacent to the backward prediction sample.
 11. The method of claim 6, wherein the sample optical flow parameters comprise a sample difference, a horizontal average gradient and a vertical average gradient.
 12. An apparatus for predicting bidirectional optical flowing, comprising: one or more processors; and a non-transitory computer-readable storage medium coupled to the one or more processors and storing programming instructions for execution by the one or more processors, wherein the one or more processors, upon executing the programming instructions, cause the apparatus to carry out operations of obtaining an initial motion vector pair for a current block, wherein the initial motion vector pair comprises a forward motion vector and a backward motion vector; obtaining a forward prediction block according to the forward motion vector and a backward prediction block according to the backward motion vector; calculating gradient parameters for a current sample in the current block based on a forward prediction sample and a backward prediction sample corresponding to the current sample, wherein the forward prediction sample is in the forward prediction block and the backward prediction sample is in the backward prediction block; obtaining at least two sample optical flow parameters for the current sample based on the gradient parameters, wherein the sample optical flow parameters comprises a first parameter and a second parameter; obtaining block optical flow parameters based on sample optical flow parameters of samples in the current block, wherein one of the block optical flow parameters is obtained by an operation including multiplying a value of the first parameter and a value of a sign function of the second parameter, and wherein the sign function is a piecewise function with at least three subintervals; and obtaining a prediction value of the current block based on the forward prediction block, the backward prediction block, the block optical flow parameters and the sample optical flow parameters.
 13. The apparatus of claim 12, wherein the sign function is ${{Sign}\mspace{11mu}(x)} = \left\{ \begin{matrix} {1;} & {x > T} \\ {0;} & {{- T} \leqslant x \leqslant T} \\ {{- 1};} & {x < {- T}} \end{matrix} \right.$ wherein T is a non-negative real number.
 14. The apparatus of claim 13, wherein T is 0; correspondingly, the sign function is ${{Sign}\mspace{11mu}(x)} = \left\{ \begin{matrix} {1;} & {x > 0} \\ {0;} & {x==0} \\ {{- 1};} & {x < 0} \end{matrix} \right.$
 15. The apparatus of claim 12, wherein the initial motion vector pair is obtained according to motion information of at least one spatial and/or temporal neighboring block of the current block.
 16. The apparatus of claim 12, wherein the current block is a coding unit or a sub-block of the coding unit.
 17. The apparatus of claim 12, wherein gradient parameters comprise a forward horizontal gradient, a backward horizontal gradient, a forward vertical gradient and a backward vertical gradient.
 18. The apparatus of claim 17, wherein the forward horizontal gradient is a difference of a right sample and a left sample adjacent to the forward prediction sample.
 19. The apparatus of claim 17, wherein the backward horizontal gradient is a difference of a right sample and a left sample adjacent to the backward prediction sample.
 20. A non-transitory computer-readable medium having stored thereon instructions that, when executed by one or more processors, cause the one or more processors to perform operations including: obtaining an initial motion vector pair for a current block, wherein the initial motion vector pair comprises a forward motion vector and a backward motion vector; obtaining a forward prediction block according to the forward motion vector and a backward prediction block according to the backward motion vector; calculating gradient parameters for a current sample in the current block based on a forward prediction sample and a backward prediction sample corresponding to the current sample, wherein the forward prediction sample is in the forward prediction block and the backward prediction sample is in the backward prediction block; obtaining at least two sample optical flow parameters for the current sample based on the gradient parameters, wherein the sample optical flow parameters comprises a first parameter and a second parameter; obtain block optical flow parameters based on sample optical flow parameters of samples in the current block, wherein one of the block optical flow parameters is obtained by an operation including multiplying a value of the first parameter and a value of a sign function of the second parameter, and wherein the sign function is a piecewise function with at least three subintervals; and obtaining a prediction value of the current block based on the forward prediction block, the backward prediction block, the block optical flow parameters and the sample optical flow parameters. 